diff --git a/WHFBCHECKS/private/Get-WHFBCA.ps1 b/WHFBCHECKS/private/Get-WHFBCA.ps1 index aee0301..757e7df 100644 --- a/WHFBCHECKS/private/Get-WHFBCA.ps1 +++ b/WHFBCHECKS/private/Get-WHFBCA.ps1 @@ -11,23 +11,31 @@ function get-WHFBCA { if ($ca.Children.cn.count -gt 1) { $res = [System.Collections.ArrayList]::new() foreach ($c in $ca) { - $CASvr = get-adcomputer $c.cn.ToString() -properties * - $caa = [PSCustomObject]@{ - Name = $c.cn - CAName = $c.children.cn[0] - OSVer = [decimal]$CASvr.OperatingSystemVersion.split(' ')[0] + try { + $CASvr = get-adcomputer $c.cn.ToString() -properties * + $caa = [PSCustomObject]@{ + Name = $c.cn + CAName = $c.children.cn[0] + OSVer = [decimal]$CASvr.OperatingSystemVersion.split(' ')[0] + } + $res.Add($caa) | out-null + } + catch { } - $res.Add($caa) | out-null } } elseif ($ca.Children.cn.count -eq 1) { - $CASvr = get-adcomputer $ca.cn -properties * - $caa = [PSCustomObject]@{ - Name = $ca.cn - CAName = $ca.children.cn[0] - OSVer = [decimal]$CASvr.OperatingSystemVersion.split(' ')[0] + try { + $CASvr = get-adcomputer $ca.cn -properties * + $caa = [PSCustomObject]@{ + Name = $ca.cn + CAName = $ca.children.cn[0] + OSVer = [decimal]$CASvr.OperatingSystemVersion.split(' ')[0] + } + $res = $caa + } + catch { } - $res = $caa } return $res } diff --git a/WHFBCHECKS/public/test-WHFB.ps1 b/WHFBCHECKS/public/test-WHFB.ps1 index 53170d7..e66a10b 100644 --- a/WHFBCHECKS/public/test-WHFB.ps1 +++ b/WHFBCHECKS/public/test-WHFB.ps1 @@ -28,13 +28,13 @@ function Test-WHFB { add-type -path "$($module.ModuleBase)\Microsoft.IdentityModel.Clients.ActiveDirectory.dll" $AuthSessions = [Microsoft.IdentityModel.Clients.ActiveDirectory.TokenCache]::DefaultShared.ReadItems() $authed = $false - foreach ($AuthSession in $AuthSessions) { - if ($AuthSession.clientid -eq "1b730954-1685-4b74-9bfd-dac224a7b894") { - if ($AuthSession.expireson -gt (Get-Date)) { - $authed = $true - } - } - } + #foreach ($AuthSession in $AuthSessions) { + # if ($AuthSession.clientid -eq "1b730954-1685-4b74-9bfd-dac224a7b894") { + # if ($AuthSession.expireson -gt (Get-Date)) { + # $authed = $true + # } + # } + #} if (!$authed) { Connect-MsolService } @@ -252,7 +252,7 @@ function Test-WHFB { else { foreach ($CertCRLDP in $CertCRLDPs) { if ( ($CertCRLDP.Contains("(")) -and ($CertCRLDP.Contains(")")) ) { - $CertCRLDP = ($CertCRLDP.Substring(($CertCRLDP.IndexOf("(") + 1))).TrimEnd(")") + $CertCRLDP = ($CertCRLDP.Substring(0,($CertCRLDP.IndexOf("(")))).TrimEnd(")") + ".crl" } Write-FormattedHost -Message "CA KDC cert on Domain Controller $($DCC.PSComputerName) HTTP CRL is:" -ResultState Pass -ResultMessage $CertCRLDP $CACRLValid = Get-WHFBCACRLValid -crl (Invoke-WebRequest -Uri $CertCRLDP -UseBasicParsing).content