@@ -16,41 +16,56 @@ 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 {
3331 if ($Options.Exclude.DCs ) {
34- $DFS = Get-WinADDFSHealth - Domain $Domain - Credential $Credential | Where-Object { $_ .DomainController -notin ( $Options.Exclude.DCs ).split( " . " , 2 )[ 0 ] }
35- } Else { $DFS = Get-WinADDFSHealth - Domain $Domain - Credential $Credential }
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 }
3634 if ($DFS ) {
3735 Section - ExcludeFromTOC - Style NOTOCHeading4 ' Sysvol Replication Status' {
38- 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()) ."
3937 BlankLine
4038 $OutObj = @ ()
41- foreach ($DCStatus in $DFS ) {
39+ foreach ($Controller in $DCs ) {
4240 try {
41+ $RepState = $DFS | Where-Object { $_.DomainController -eq $Controller.Split (' .' )[0 ] } | Select-Object - Property ReplicationState, GroupPolicyCount, SysvolCount, IdenticalCount, StopReplicationOnAutoRecovery
4342 $inObj = [ordered ] @ {
44- ' DC Name' = $DCStatus.DomainController
45- ' Replication Status' = Switch ([string ]::IsNullOrEmpty($DCStatus.ReplicationState )) {
46- $true { " Unknown" }
47- $false { $DCStatus.ReplicationState }
43+ ' DC Name' = $Controller.Split (' .' )[0 ]
44+ ' Replication Status' = Switch ([string ]::IsNullOrEmpty($RepState.ReplicationState )) {
45+ $true { " Offline" }
46+ $false { $RepState.ReplicationState }
47+ default { " --" }
48+ }
49+ ' GPO Count' = switch ([string ]::IsNullOrEmpty($RepState.GroupPolicyCount )) {
50+ $true { " 0" }
51+ $false { $RepState.GroupPolicyCount }
52+ default { " --" }
53+ }
54+ ' Sysvol Count' = switch ([string ]::IsNullOrEmpty($RepState.SysvolCount )) {
55+ $true { " 0" }
56+ $false { $RepState.SysvolCount }
57+ default { " --" }
58+ }
59+ ' Identical Count' = switch ([string ]::IsNullOrEmpty($RepState.IdenticalCount )) {
60+ $true { " 0" }
61+ $false { $RepState.IdenticalCount }
62+ default { " --" }
63+ }
64+ ' Stop Replication On AutoRecovery' = switch ([string ]::IsNullOrEmpty($RepState.StopReplicationOnAutoRecovery )) {
65+ $true { " 0" }
66+ $false { $RepState.StopReplicationOnAutoRecovery }
4867 default { " --" }
4968 }
50- ' GPO Count' = $DCStatus.GroupPolicyCount
51- ' Sysvol Count' = $DCStatus.SysvolCount
52- ' Identical Count' = $DCStatus.IdenticalCount
53- ' Stop Replication On AutoRecovery' = $DCStatus.StopReplicationOnAutoRecovery
5469
5570 }
5671 $OutObj += [pscustomobject ](ConvertTo-HashToYN $inObj )
@@ -77,7 +92,7 @@ function Get-AbrADDFSHealth {
7792 }
7893
7994 $TableParams = @ {
80- Name = " Sysvol Replication Status - $ ( $Domain.ToString ().ToUpper()) "
95+ Name = " Sysvol Replication Status - $ ( $Domain.DNSRoot. ToString ().ToUpper() ) )"
8196 List = $false
8297 ColumnWidths = 20 , 16 , 16 , 16 , 16 , 16
8398 }
@@ -97,18 +112,17 @@ function Get-AbrADDFSHealth {
97112 }
98113 }
99114 } else {
100- Write-PScriboMessage " No DFS information found in $Domain , Disabling this section."
115+ Write-PScriboMessage " No DFS information found in $ ( $ Domain.DNSRoot ) , Disabling this section."
101116 }
102117 } catch {
103118 Write-PScriboMessage - IsWarning " Sysvol Replication Status Table Section: $ ( $_.Exception.Message ) "
104119 }
105120 try {
106- $DC = Get-ValidDCfromDomain - Domain $Domain
107121
108- $DCPssSession = Get-ValidPSSession - ComputerName $DC - SessionName $ ($DC )
122+ $DCPssSession = Get-ValidPSSession - ComputerName $ValidDcFromDomain - SessionName $ ($ValidDcFromDomain ) - PSSTable ([ ref ] $PSSTable )
109123 if ($DCPssSession ) {
110124 # Code taken from ClaudioMerola (https://github.com/ClaudioMerola/ADxRay)
111- $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 {
112126 New-Object - TypeName PSObject - Property @ {
113127 ' Extension' = $_.name
114128 ' Count' = $_.count
@@ -118,11 +132,11 @@ function Get-AbrADDFSHealth {
118132 if (-Not $_.Exception.MessageId ) {
119133 $ErrorMessage = $_.FullyQualifiedErrorId
120134 } else { $ErrorMessage = $_.Exception.MessageId }
121- 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 "
122136 }
123137 if ($SYSVOLFolder ) {
124138 Section - ExcludeFromTOC - Style NOTOCHeading4 ' Sysvol Content Status' {
125- 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."
126140 BlankLine
127141 $OutObj = @ ()
128142 foreach ($Extension in $SYSVOLFolder ) {
@@ -143,7 +157,7 @@ function Get-AbrADDFSHealth {
143157 }
144158
145159 $TableParams = @ {
146- Name = " Sysvol Content Status - $ ( $Domain.ToString ().ToUpper()) "
160+ Name = " Sysvol Content Status - $ ( $Domain.DNSRoot. ToString ().ToUpper()) "
147161 List = $false
148162 ColumnWidths = 33 , 33 , 34
149163 }
@@ -162,17 +176,16 @@ function Get-AbrADDFSHealth {
162176 }
163177 }
164178 } else {
165- 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."
166180 }
167181 } catch {
168182 Write-PScriboMessage - IsWarning " Sysvol Health Table Section: $ ( $_.Exception.Message ) "
169183 }
170184 try {
171- $DC = Get-ValidDCfromDomain - Domain $Domain
172- $DCPssSession = Get-ValidPSSession - ComputerName $DC - SessionName $ ($DC )
185+ $DCPssSession = Get-ValidPSSession - ComputerName $ValidDcFromDomain - SessionName $ ($ValidDcFromDomain ) - PSSTable ([ref ]$PSSTable )
173186 if ($DCPssSession ) {
174187 # Code taken from ClaudioMerola (https://github.com/ClaudioMerola/ADxRay)
175- $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 {
176189 New-Object - TypeName PSObject - Property @ {
177190 ' Extension' = $_.name
178191 ' Count' = $_.count
@@ -182,11 +195,11 @@ function Get-AbrADDFSHealth {
182195 if (-Not $_.Exception.MessageId ) {
183196 $ErrorMessage = $_.FullyQualifiedErrorId
184197 } else { $ErrorMessage = $_.Exception.MessageId }
185- 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 "
186199 }
187200 if ($NetlogonFolder ) {
188201 Section - ExcludeFromTOC - Style NOTOCHeading4 ' Netlogon Content Status' {
189- 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."
190203 BlankLine
191204 $OutObj = @ ()
192205 foreach ($Extension in $NetlogonFolder ) {
@@ -207,7 +220,7 @@ function Get-AbrADDFSHealth {
207220 }
208221
209222 $TableParams = @ {
210- Name = " Netlogon Content Status - $ ( $Domain.ToString ().ToUpper()) "
223+ Name = " Netlogon Content Status - $ ( $Domain.DNSRoot. ToString ().ToUpper()) "
211224 List = $false
212225 ColumnWidths = 33 , 33 , 34
213226 }
@@ -226,7 +239,7 @@ function Get-AbrADDFSHealth {
226239 }
227240 }
228241 } else {
229- 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."
230243 }
231244 } catch {
232245 Write-PScriboMessage - IsWarning " Netlogon Content Status Section: $ ( $_.Exception.Message ) "
0 commit comments