-
Notifications
You must be signed in to change notification settings - Fork 0
/
Compare-Certificates.ps1
30 lines (23 loc) · 1.24 KB
/
Compare-Certificates.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# RCautomate.com
# Compare the Certificates between two machines, export to CSV
# This can be useful to determine certificate or authentication behavioral differences between PCs.
# $computer is assumed to be the current running PC unless otherwise specified.
#Compare these two machines
$HOSTNAME1 = "HOSTNAME1"
$HOSTNAME2 = "HOSTNAME2"
function Get-Certificates {
Param(
$Computer = $env:COMPUTERNAME,
[System.Security.Cryptography.X509Certificates.StoreLocation]$StoreLocation,
[System.Security.Cryptography.X509Certificates.StoreName]$StoreName
)
$Store = New-Object System.Security.Cryptography.X509Certificates.X509Store("\\$computer\$StoreName",$StoreLocation)
$Store.Open([System.Security.Cryptography.X509Certificates.OpenFlags]"ReadOnly")
$Store.Certificates
}
$Left = Get-Certificates -StoreLocation LocalMachine -StoreName Root -Computer $HOSTNAME1
$Right = Get-Certificates -StoreLocation LocalMachine -StoreName Root -Computer $HOSTNAME2
# Dump to console
Compare-Object $Right $Left -property Thumbprint, FriendlyName, Subject, NotAfter | Format-Table
# Export results to file
#Compare-Object $Left $Right -property Thumbprint, FriendlyName, Subject, NotAfter | Export-Csv Comparison.csv