|
28 | 28 | Check all certificates on the local machine: |
29 | 29 | PS C:\> .\Test-SCOMCertificates.ps1 -All |
30 | 30 | .NOTES |
| 31 | + Update 05/2024 (Blake Drumm, https://blakedrumm.com/) |
| 32 | + Updated the way the subject name is parsed against the DNS resolved name of the machine. |
31 | 33 | Update 03/2024 (Blake Drumm, https://blakedrumm.com/) |
32 | 34 | Changed the name from Start-SCOMCertificateChecker to Test-SCOMCertificate. |
33 | 35 | Update 05/2023 (Blake Drumm, https://blakedrumm.com/) |
@@ -286,15 +288,14 @@ $($ChainCertsOutput) |
286 | 288 | $out += "`n" + "`n" + $text4 |
287 | 289 | $pass = $true |
288 | 290 | # Check subjectname |
289 | | - $fqdn = $env:ComputerName |
290 | | - $fqdn += "." + [DirectoryServices.ActiveDirectory.Domain]::GetComputerDomain().Name |
| 291 | + $fqdn = (Resolve-DnsName $env:COMPUTERNAME -Type A | Select-Object -ExpandProperty Name -Unique) -join " " |
291 | 292 | trap [DirectoryServices.ActiveDirectory.ActiveDirectoryObjectNotFoundException] |
292 | 293 | { |
293 | 294 | # Not part of a domain |
294 | 295 | continue; |
295 | 296 | } |
296 | 297 | $subjectProblem = $false |
297 | | - $fqdnRegexPattern = "CN=" + $fqdn.Replace(".", "\.") + '(,.*)?$' |
| 298 | + $fqdnRegexPattern = "CN=" + ($fqdn.Replace(".", "\.")).Replace(" ", "|CN=") |
298 | 299 | try { $CheckForDuplicateSubjectCNs = ((($cert).Subject).Split(",") | %{ $_.Trim() } | Where { $_ -match "CN=" }).Trim("CN=") | % { $_.Split(".") | Select-Object -First 1 } | Group-Object | Where-Object { $_.Count -gt 1 } | Select -ExpandProperty Name } |
299 | 300 | catch { $CheckForDuplicateSubjectCNs = $null } |
300 | 301 |
|
@@ -755,6 +756,7 @@ Certificate Checker |
755 | 756 | continue |
756 | 757 | } |
757 | 758 | #endregion Function |
| 759 | + |
758 | 760 | #region DefaultActions |
759 | 761 | if ($Servers -or $OutputFile -or $All -or $SerialNumber) |
760 | 762 | { |
|
0 commit comments