@@ -16,28 +16,24 @@ function Get-AbrADDFSHealth {
1616 #>
1717 [CmdletBinding ()]
1818 param (
19- [Parameter (
20- Position = 0 ,
21- Mandatory )]
22- [string ]
23- $Domain
19+ $Domain ,
20+ [string []]$DCs ,
21+ $ValidDcFromDomain
2422 )
2523
2624 begin {
27- Write-PScriboMessage " Collecting AD Domain DFS Health information on $Domain ."
25+ Write-PScriboMessage " Collecting AD Domain DFS Health information on $ ( $ Domain.DNSRoot ) ."
2826 }
2927
3028 process {
3129 if ($HealthCheck.Domain.DFS ) {
3230 try {
33- $DCs = Invoke-Command - Session $TempPssSession { Get-ADDomain - Identity $using :Domain | Select-Object - ExpandProperty ReplicaDirectoryServers | Where-Object { $_ -notin ($using :Options ).Exclude.DCs } } | Sort-Object
34-
3531 if ($Options.Exclude.DCs ) {
36- $DFS = Get-WinADDFSHealth - Domain $Domain - Credential $Credential - ExcludeDomains $Options.Exclude.Domains - ExcludeDomainControllers $Options.Exclude.DCs
37- } Else { $DFS = Get-WinADDFSHealth - Domain $Domain - Credential $Credential - ExcludeDomains $Options.Exclude.Domains }
32+ $DFS = Get-WinADDFSHealth - Domain $Domain.DNSRoot - Credential $Credential - ExcludeDomains $Options.Exclude.Domains - ExcludeDomainControllers $Options.Exclude.DCs
33+ } Else { $DFS = Get-WinADDFSHealth - Domain $Domain.DNSRoot - Credential $Credential - ExcludeDomains $Options.Exclude.Domains }
3834 if ($DFS ) {
3935 Section - ExcludeFromTOC - Style NOTOCHeading4 ' Sysvol Replication Status' {
40- Paragraph " The following section details the sysvol folder replication status for Domain $ ( $Domain.ToString ().ToUpper()) ."
36+ Paragraph " The following section details the sysvol folder replication status for Domain $ ( $Domain.DNSRoot. ToString ().ToUpper()) ."
4137 BlankLine
4238 $OutObj = @ ()
4339 foreach ($Controller in $DCs ) {
@@ -96,7 +92,7 @@ function Get-AbrADDFSHealth {
9692 }
9793
9894 $TableParams = @ {
99- Name = " Sysvol Replication Status - $ ( $Domain.ToString ().ToUpper()) "
95+ Name = " Sysvol Replication Status - $ ( $Domain.DNSRoot. ToString ().ToUpper() ) )"
10096 List = $false
10197 ColumnWidths = 20 , 16 , 16 , 16 , 16 , 16
10298 }
@@ -116,18 +112,17 @@ function Get-AbrADDFSHealth {
116112 }
117113 }
118114 } else {
119- Write-PScriboMessage " No DFS information found in $Domain , Disabling this section."
115+ Write-PScriboMessage " No DFS information found in $ ( $ Domain.DNSRoot ) , Disabling this section."
120116 }
121117 } catch {
122118 Write-PScriboMessage - IsWarning " Sysvol Replication Status Table Section: $ ( $_.Exception.Message ) "
123119 }
124120 try {
125- $DC = Get-ValidDCfromDomain - Domain $Domain - DCStatus ([ref ]$DCStatus )
126121
127- $DCPssSession = Get-ValidPSSession - ComputerName $DC - SessionName $ ($DC ) - PSSTable ([ref ]$PSSTable )
122+ $DCPssSession = Get-ValidPSSession - ComputerName $ValidDcFromDomain - SessionName $ ($ValidDcFromDomain ) - PSSTable ([ref ]$PSSTable )
128123 if ($DCPssSession ) {
129124 # Code taken from ClaudioMerola (https://github.com/ClaudioMerola/ADxRay)
130- $SYSVOLFolder = Invoke-Command - Session $DCPssSession { Get-ChildItem - Path $ (' \\' + $using :Domain + ' \SYSVOL\' + $using :Domain ) - Recurse | Where-Object - FilterScript { $_.PSIsContainer -eq $false } | Group-Object - Property Extension | ForEach-Object - Process {
125+ $SYSVOLFolder = Invoke-Command - Session $DCPssSession { Get-ChildItem - Path $ (' \\' + ( $using :Domain ).DNSRoot + ' \SYSVOL\' + ( $using :Domain ).DNSRoot ) - Recurse | Where-Object - FilterScript { $_.PSIsContainer -eq $false } | Group-Object - Property Extension | ForEach-Object - Process {
131126 New-Object - TypeName PSObject - Property @ {
132127 ' Extension' = $_.name
133128 ' Count' = $_.count
@@ -137,11 +132,11 @@ function Get-AbrADDFSHealth {
137132 if (-Not $_.Exception.MessageId ) {
138133 $ErrorMessage = $_.FullyQualifiedErrorId
139134 } else { $ErrorMessage = $_.Exception.MessageId }
140- Write-PScriboMessage - IsWarning " Sysvol Content Status Section: New-PSSession: Unable to connect to $ ( $DC ) : $ErrorMessage "
135+ Write-PScriboMessage - IsWarning " Sysvol Content Status Section: New-PSSession: Unable to connect to $ ( $ValidDcFromDomain ) : $ErrorMessage "
141136 }
142137 if ($SYSVOLFolder ) {
143138 Section - ExcludeFromTOC - Style NOTOCHeading4 ' Sysvol Content Status' {
144- Paragraph " The following section details domain $ ( $Domain.ToString ().ToUpper()) sysvol health status."
139+ Paragraph " The following section details domain $ ( $Domain.DNSRoot. ToString ().ToUpper() ) ) sysvol health status."
145140 BlankLine
146141 $OutObj = @ ()
147142 foreach ($Extension in $SYSVOLFolder ) {
@@ -162,7 +157,7 @@ function Get-AbrADDFSHealth {
162157 }
163158
164159 $TableParams = @ {
165- Name = " Sysvol Content Status - $ ( $Domain.ToString ().ToUpper()) "
160+ Name = " Sysvol Content Status - $ ( $Domain.DNSRoot. ToString ().ToUpper()) "
166161 List = $false
167162 ColumnWidths = 33 , 33 , 34
168163 }
@@ -181,17 +176,16 @@ function Get-AbrADDFSHealth {
181176 }
182177 }
183178 } else {
184- Write-PScriboMessage " No SYSVOL folder information found in $Domain , Disabling this section."
179+ Write-PScriboMessage " No SYSVOL folder information found in $ ( $ Domain.DNSRoot ) , Disabling this section."
185180 }
186181 } catch {
187182 Write-PScriboMessage - IsWarning " Sysvol Health Table Section: $ ( $_.Exception.Message ) "
188183 }
189184 try {
190- $DC = Get-ValidDCfromDomain - Domain $Domain - DCStatus ([ref ]$DCStatus )
191- $DCPssSession = Get-ValidPSSession - ComputerName $DC - SessionName $ ($DC ) - PSSTable ([ref ]$PSSTable )
185+ $DCPssSession = Get-ValidPSSession - ComputerName $ValidDcFromDomain - SessionName $ ($ValidDcFromDomain ) - PSSTable ([ref ]$PSSTable )
192186 if ($DCPssSession ) {
193187 # Code taken from ClaudioMerola (https://github.com/ClaudioMerola/ADxRay)
194- $NetlogonFolder = Invoke-Command - Session $DCPssSession { Get-ChildItem - Path $ (' \\' + $using :Domain + ' \NETLOGON\' ) - Recurse | Where-Object - FilterScript { $_.PSIsContainer -eq $false } | Group-Object - Property Extension | ForEach-Object - Process {
188+ $NetlogonFolder = Invoke-Command - Session $DCPssSession { Get-ChildItem - Path $ (' \\' + ( $using :Domain ).DNSRoot + ' \NETLOGON\' ) - Recurse | Where-Object - FilterScript { $_.PSIsContainer -eq $false } | Group-Object - Property Extension | ForEach-Object - Process {
195189 New-Object - TypeName PSObject - Property @ {
196190 ' Extension' = $_.name
197191 ' Count' = $_.count
@@ -201,11 +195,11 @@ function Get-AbrADDFSHealth {
201195 if (-Not $_.Exception.MessageId ) {
202196 $ErrorMessage = $_.FullyQualifiedErrorId
203197 } else { $ErrorMessage = $_.Exception.MessageId }
204- Write-PScriboMessage - IsWarning " Netlogon Content Status Section: New-PSSession: Unable to connect to $ ( $DC ) : $ErrorMessage "
198+ Write-PScriboMessage - IsWarning " Netlogon Content Status Section: New-PSSession: Unable to connect to $ ( $ValidDcFromDomain ) : $ErrorMessage "
205199 }
206200 if ($NetlogonFolder ) {
207201 Section - ExcludeFromTOC - Style NOTOCHeading4 ' Netlogon Content Status' {
208- Paragraph " The following section details domain $ ( $Domain.ToString ().ToUpper()) netlogon health status."
202+ Paragraph " The following section details domain $ ( $Domain.DNSRoot. ToString ().ToUpper() ) ) netlogon health status."
209203 BlankLine
210204 $OutObj = @ ()
211205 foreach ($Extension in $NetlogonFolder ) {
@@ -226,7 +220,7 @@ function Get-AbrADDFSHealth {
226220 }
227221
228222 $TableParams = @ {
229- Name = " Netlogon Content Status - $ ( $Domain.ToString ().ToUpper()) "
223+ Name = " Netlogon Content Status - $ ( $Domain.DNSRoot. ToString ().ToUpper()) "
230224 List = $false
231225 ColumnWidths = 33 , 33 , 34
232226 }
@@ -245,7 +239,7 @@ function Get-AbrADDFSHealth {
245239 }
246240 }
247241 } else {
248- Write-PScriboMessage " No NETLOGON folder information found in $Domain , Disabling this section."
242+ Write-PScriboMessage " No NETLOGON folder information found in $ ( $ Domain.DNSRoot ) , Disabling this section."
249243 }
250244 } catch {
251245 Write-PScriboMessage - IsWarning " Netlogon Content Status Section: $ ( $_.Exception.Message ) "
0 commit comments