@@ -35,7 +35,8 @@ function Get-AbrADDNSInfrastructure {
3535 foreach ($DC in $DCs ) {
3636 if (Get-DCWinRMState - ComputerName $DC - DCStatus ([ref ]$DCStatus )) {
3737 try {
38- $DNSSetting = Get-DnsServerSetting - CimSession $TempCIMSession - ComputerName $DC
38+ $DCCimSession = Get-ValidCIMSession - ComputerName $DC - SessionName " $ ( $DC ) _DNS" - CIMTable ([ref ]$CIMTable )
39+ $DNSSetting = Get-DnsServerSetting - CimSession $DCCimSession - ComputerName $DC
3940 $inObj = [ordered ] @ {
4041 ' DC Name' = $ ($DC.ToString ().ToUpper().Split(' .' )[0 ])
4142 ' Build Number' = $DNSSetting.BuildNumber
@@ -73,7 +74,8 @@ function Get-AbrADDNSInfrastructure {
7374 try {
7475 Section - ExcludeFromTOC - Style NOTOCHeading5 $ ($DC.ToString ().ToUpper().Split(' .' )[0 ]) {
7576 $OutObj = [System.Collections.ArrayList ]::new()
76- $DNSSetting = Get-DnsServerDirectoryPartition - CimSession $TempCIMSession - ComputerName $DC
77+ $DCCimSession = Get-ValidCIMSession - ComputerName $DC - SessionName " $ ( $DC ) _DNS" - CIMTable ([ref ]$CIMTable )
78+ $DNSSetting = Get-DnsServerDirectoryPartition - CimSession $DCCimSession - ComputerName $DC
7779 foreach ($Partition in $DNSSetting ) {
7880 try {
7981 $inObj = [ordered ] @ {
@@ -124,7 +126,8 @@ function Get-AbrADDNSInfrastructure {
124126 foreach ($DC in $DCs ) {
125127 if (Get-DCWinRMState - ComputerName $DC - DCStatus ([ref ]$DCStatus )) {
126128 try {
127- $DNSSetting = Get-DnsServerResponseRateLimiting - CimSession $TempCIMSession - ComputerName $DC
129+ $DCCimSession = Get-ValidCIMSession - ComputerName $DC - SessionName " $ ( $DC ) _DNS" - CIMTable ([ref ]$CIMTable )
130+ $DNSSetting = Get-DnsServerResponseRateLimiting - CimSession $DCCimSession - ComputerName $DC
128131 $inObj = [ordered ] @ {
129132 ' DC Name' = $ ($DC.ToString ().ToUpper().Split(' .' )[0 ])
130133 ' Status' = $DNSSetting.Mode
@@ -166,7 +169,8 @@ function Get-AbrADDNSInfrastructure {
166169 foreach ($DC in $DCs ) {
167170 if (Get-DCWinRMState - ComputerName $DC - DCStatus ([ref ]$DCStatus )) {
168171 try {
169- $DNSSetting = Get-DnsServerScavenging - CimSession $TempCIMSession - ComputerName $DC
172+ $DCCimSession = Get-ValidCIMSession - ComputerName $DC - SessionName " $ ( $DC ) _DNS" - CIMTable ([ref ]$CIMTable )
173+ $DNSSetting = Get-DnsServerScavenging - CimSession $DCCimSession - ComputerName $DC
170174 $inObj = [ordered ] @ {
171175 ' DC Name' = $ ($DC.ToString ().ToUpper().Split(' .' )[0 ])
172176 ' NoRefresh Interval' = $DNSSetting.NoRefreshInterval
@@ -225,8 +229,9 @@ function Get-AbrADDNSInfrastructure {
225229 foreach ($DC in $DCs ) {
226230 if (Get-DCWinRMState - ComputerName $DC - DCStatus ([ref ]$DCStatus )) {
227231 try {
228- $DNSSetting = Get-DnsServerForwarder - CimSession $TempCIMSession - ComputerName $DC
229- $Recursion = Get-DnsServerRecursion - CimSession $TempCIMSession - ComputerName $DC | Select-Object - ExpandProperty Enable
232+ $DCCimSession = Get-ValidCIMSession - ComputerName $DC - SessionName " $ ( $DC ) _DNS" - CIMTable ([ref ]$CIMTable )
233+ $DNSSetting = Get-DnsServerForwarder - CimSession $DCCimSession - ComputerName $DC
234+ $Recursion = Get-DnsServerRecursion - CimSession $DCCimSession - ComputerName $DC | Select-Object - ExpandProperty Enable
230235 $inObj = [ordered ] @ {
231236 ' DC Name' = $ ($DC.ToString ().ToUpper().Split(' .' )[0 ])
232237 ' IP Address' = $DNSSetting.IPAddress.IPAddressToString
@@ -295,7 +300,8 @@ function Get-AbrADDNSInfrastructure {
295300 try {
296301 Section - ExcludeFromTOC - Style NOTOCHeading5 $ ($DC.ToString ().ToUpper().Split(' .' )[0 ]) {
297302 $OutObj = [System.Collections.ArrayList ]::new()
298- $DNSSetting = Get-DnsServerRootHint - CimSession $TempCIMSession - ComputerName $DC - ErrorAction SilentlyContinue | Select-Object @ {Name = ' Name' ; E = { $_.NameServer.RecordData.Nameserver } }, @ { Name = ' IPv4Address' ; E = { $_.IPAddress.RecordData.IPv4Address.IPAddressToString } }, @ { Name = ' IPv6Address' ; E = { $_.IPAddress.RecordData.IPv6Address.IPAddressToString } }
303+ $DCCimSession = Get-ValidCIMSession - ComputerName $DC - SessionName " $ ( $DC ) _DNS" - CIMTable ([ref ]$CIMTable )
304+ $DNSSetting = Get-DnsServerRootHint - CimSession $DCCimSession - ComputerName $DC - ErrorAction SilentlyContinue | Select-Object @ {Name = ' Name' ; E = { $_.NameServer.RecordData.Nameserver } }, @ { Name = ' IPv4Address' ; E = { $_.IPAddress.RecordData.IPv4Address.IPAddressToString } }, @ { Name = ' IPv6Address' ; E = { $_.IPAddress.RecordData.IPv6Address.IPAddressToString } }
299305 if ($DNSSetting ) {
300306 foreach ($Hints in $DNSSetting ) {
301307 try {
@@ -396,7 +402,8 @@ function Get-AbrADDNSInfrastructure {
396402 foreach ($DC in $DCs ) {
397403 if (Get-DCWinRMState - ComputerName $DC - DCStatus ([ref ]$DCStatus )) {
398404 try {
399- $DNSSetting = Get-DnsServerRecursionScope - CimSession $TempCIMSession - ComputerName $DC
405+ $DCCimSession = Get-ValidCIMSession - ComputerName $DC - SessionName " $ ( $DC ) _DNS" - CIMTable ([ref ]$CIMTable )
406+ $DNSSetting = Get-DnsServerRecursionScope - CimSession $DCCimSession - ComputerName $DC
400407 $inObj = [ordered ] @ {
401408 ' DC Name' = $ ($DC.ToString ().ToUpper().Split(' .' )[0 ])
402409 ' Zone Name' = switch ($DNSSetting.Name ) {
0 commit comments