Category filter
Script to get details of all certificates on Windows devices
Organizations may need to check that only valid and trusted certificates are used on devices to ensure the proper functioning of the organization. These details can help admins to plan for certificate expirations and renewals. But reviewing every certificate is a tiresome task. Using Hexnode UEM’s Execute Custom Script feature, you can remotely fetch certificates detail on Windows devices.
PowerShell script
1 |
Get-ChildItem Cert:\LocalMachine\Root\ |
1 |
Get-ChildItem Cert:\LocalMachine\Root\ | where{$_.FriendlyName -eq 'FriendlyName'} |
E.g., To get details of a certificate having the FriendlyName of “DigiCert” from the Root store.
Get-ChildItem Cert:\LocalMachine\Root\ | where{$_.FriendlyName -eq 'DigiCert'}
1 |
Get-ChildItem Cert:\LocalMachine\ -Recurse | where{$_.FriendlyName -eq 'FriendlyName'} |
E.g., To get details of a certificate having FriendlyName of “DigiCert” present in all other certificate stores.
Get-ChildItem Cert:\LocalMachine\ -Recurse | where{$_.FriendlyName -eq 'DigiCert'}
1 |
Get-ChildItem Cert:\ -Recurse |
1 |
Get-ChildItem Cert:\LocalMachine\root | where{$_.FriendlyName -eq 'FriendlyName'} | fl * |
E.g., To get full details of the certificate with the FriendlyName of “DigiCert”.
Get-ChildItem Cert:\LocalMachine\root | where{$_.FriendlyName -eq 'DigiCert'} | fl *
1 2 3 4 5 6 7 8 9 10 11 |
$thumbprint = '<thumbprint>' $stores = @('Cert:\CurrentUser\My', 'Cert:\LocalMachine\My') foreach ($store in $stores) { $cert = Get-ChildItem -Path $store | Where-Object {$_.Thumbprint -eq $thumbprint} if ($cert) { Write-Host "Certificate found in $store" $cert } else { Write-Host "Certificate not found in $store" } } |
E.g., To get details of a certificate having thumbprint of “4B789A3918C60107A19F629FCA3FEB4FE9CAD49A” present in all other certificate stores.
$thumbprint = '4B789A3918C60107A19F629FCA3FEB4FE9CAD49A'
$stores = @('Cert:\CurrentUser\My', 'Cert:\LocalMachine\My')
foreach ($store in $stores) {
$cert = Get-ChildItem -Path $store | Where-Object {$_.Thumbprint -eq $thumbprint}
if ($cert) {
Write-Host "Certificate found in $store"
$cert
} else {
Write-Host "Certificate not found in $store"
}
}
1 |
Get-ChildItem -Path Cert: -recurse -ExpiringInDays ‘Days’ |
E.g., To get details of a certificates expiring in 30 days
Get-ChildItem -Path Cert: -recurse -ExpiringInDays 30