Skip to content

Commit

Permalink
Create Get-NonStandardRootCerts.ps1
Browse files Browse the repository at this point in the history
  • Loading branch information
gtworek authored Nov 3, 2024
1 parent 8c9b957 commit 18a9481
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions RootCerts/Get-NonStandardRootCerts.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
$content = $null
$content = (Invoke-WebRequest https://raw.githubusercontent.com/gtworek/PSBits/refs/heads/master/RootCerts/KnownCerts.txt).Content
if (!$content)
{
Write-Host 'Cannot download list of certs. Exiting.' -ForegroundColor Red
}
else
{
#Extract thumbprints
$legitCerts = $content.Split("`n")
$legitCerts = $legitCerts | Where-Object { $_.Trim() -ne '' }
$legitCerts = $legitCerts | Where-Object { $_.Substring(0, 1) -ne ';' }

#Grab certs
$machineRootCerts = dir Cert:\LocalMachine\Root
$userRootCerts = dir Cert:\CurrentUser\Root

#Analyze
$allRootCerts = $machineRootCerts + $userRootCerts
$diffCerts = $allRootCerts | Where-Object {$_.Thumbprint -notin $legitCerts}

#Display
if ($diffCerts.Count -eq 0)
{
Write-Host 'All your certs are present on the list.' -ForegroundColor Green
}
foreach ($cert in $diffCerts)
{
Write-Host (($cert.PSPath -split '::')[1]+"`t"+$cert.Issuer) -ForegroundColor Red
}
}

0 comments on commit 18a9481

Please sign in to comment.