Skip to content

Commit 3994c49

Browse files
authored
Merge pull request #202 from rebelinux/dev
v0.9.4 WIP
2 parents 6a6dc93 + 86c8cec commit 3994c49

33 files changed

+9644
-2826
lines changed

.github/workflows/PSScriptAnalyzerSettings.psd1

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
@{
22
ExcludeRules = @(
33
'PSUseToExportFieldsInManifest'
4+
'PSAvoidUsingWriteHost'
45
)
56
Rules = @{
67
PSAvoidExclaimOperator = @{
@@ -12,5 +13,11 @@
1213
UseCorrectCasing = @{
1314
Enable = $true
1415
}
16+
PSAvoidUsingCmdletAliases = @{
17+
Enable = $true
18+
}
19+
PSUseConsistentWhitespace = @{
20+
Enable = $true
21+
}
1522
}
1623
}

AsBuiltReport.Microsoft.AD.json

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,26 @@
2121
"WinRMSSL": false,
2222
"WinRMFallbackToNoSSL": true,
2323
"WinRMSSLPort": 5986,
24-
"WinRMPort": 5985
24+
"WinRMPort": 5985,
25+
"EnableDiagrams": true,
26+
"EnableDiagramDebug": false,
27+
"DiagramTheme": "White",
28+
"DiagramObjDebug": false,
29+
"DiagramWaterMark": "",
30+
"DiagramType": {
31+
"CertificateAuthority": false,
32+
"Forest": false,
33+
"Sites": false,
34+
"SitesInventory": false,
35+
"Trusts": false
36+
},
37+
"ExportDiagrams": false,
38+
"ExportDiagramsFormat": [
39+
"png"
40+
],
41+
"EnableDiagramSignature": false,
42+
"SignatureAuthorName": "",
43+
"SignatureCompanyName": ""
2544
},
2645
"InfoLevel": {
2746
"_comment_": "0 = Disabled, 1 = Enabled, 2 = Adv Summary, 3 = Detailed",
@@ -56,12 +75,11 @@
5675
"DP": true,
5776
"Zones": true,
5877
"BestPractice": true
59-
6078
},
6179
"CA": {
6280
"Status": true,
6381
"Statistics": true,
6482
"BestPractice": true
6583
}
6684
}
67-
}
85+
}

AsBuiltReport.Microsoft.AD.psd1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@
6666
},
6767
@{
6868
ModuleName = 'Diagrammer.Microsoft.AD';
69-
ModuleVersion = '0.2.9'
69+
ModuleVersion = '0.2.14'
7070
},
7171
@{
7272
ModuleName = 'Diagrammer.Core';
73-
ModuleVersion = '0.2.19'
73+
ModuleVersion = '0.2.24'
7474
}
7575

7676
)

CHANGELOG.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,36 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
##### This project is community maintained and has no sponsorship from Microsoft, its employees or any of its affiliates.
99

10-
## [0.9.4] - Unreleased
10+
## [0.9.4] - 2025-04-24
11+
12+
### Added
13+
14+
- Add a new section in Get-AbrDomainSection to retrieve and sort DCs while excluding specified ones, enhancing the overall structure and clarity of the script.
15+
- Add diagram options to configuration file for various sections.
16+
- Introduced Get-AbrDiagrammer function to generate diagrams in multiple formats.
1117

1218
### Changed
1319

1420
- Increase AsBuiltReport.Core to v1.4.3
1521
- Increase Diagrammer.Core minimum requirement
1622
- Increase Diagrammer.Microsoft.AD minumum requirement
23+
- Improve Get-ValidCimSession,Get-ValidPSSession to detect current connected DC
24+
- Reuse the WinRM session
25+
- Reuse the CIM session
26+
- Improve DNS settings retrieval by filtering only active network adapters in Get-AbrADDomainController function
27+
- Update Sample report
28+
- Improve Get-AbrADSite to handle cases where information cannot be collected from DCs, ensuring that the output remains informative and consistent.
29+
- Update existing functions to utilize new diagram features and handle domain status.
30+
- Improve error handling and reporting for offline domains and DCs.
31+
- Updated Get-AbrDNSSection to better handle domain status checks and improve logging clarity.
32+
- Refined Get-AbrDomainSection to ensure consistent domain information retrieval and improved error handling.
33+
- Updated Get-AbrADOU to utilize DNSRoot for domain references and improved error handling.
34+
- Modified Get-AbrADSecurityAssessment to enhance domain information retrieval and output formatting.
35+
- Enhanced Get-AbrADSiteReplication to streamline domain controller handling and improve logging messages.
36+
- Revised Get-AbrADTrust to ensure consistent use of DNSRoot and improved trust information retrieval.
37+
- Enhanced SharedUtilsFunctions to improve session management and error handling for WinRM connections.
38+
- Get-ValidCIMSession
39+
- Get-ValidPSSession
1740

1841
### Fixed
1942

Samples/Sample Microsoft AD As Built Report.html

Lines changed: 7813 additions & 1393 deletions
Large diffs are not rendered by default.

Src/Private/Get-AbrADDCRoleFeature.ps1

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ function Get-AbrADDCRoleFeature {
1616
#>
1717
[CmdletBinding()]
1818
param (
19-
[Parameter (
20-
Position = 0,
21-
Mandatory)]
22-
[string]
2319
$DC
2420
)
2521

@@ -29,7 +25,7 @@ function Get-AbrADDCRoleFeature {
2925

3026
process {
3127
try {
32-
$DCPssSession = Get-ValidPSSession -ComputerName $DC -SessionName $($DC)
28+
$DCPssSession = Get-ValidPSSession -ComputerName $DC -SessionName $($DC) -PSSTable ([ref]$PSSTable)
3329
if ($DCPssSession) {
3430
$Features = Invoke-Command -Session $DCPssSession -ScriptBlock { Get-WindowsFeature | Where-Object { $_.installed -eq "True" -and $_.FeatureType -eq 'Role' } }
3531
} else {

Src/Private/Get-AbrADDFSHealth.ps1

Lines changed: 47 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)