PowerShell
PowerShell
Iterate over Certificates in a Certificate Store
See more Cert Store Examples
Demonstrates how to iterate over the certificates in a certificate store.Note: Requires Chilkat v10.1.2 or later.
Chilkat PowerShell Downloads
Add-Type -Path "C:\chilkat\ChilkatDotNet47-x64\ChilkatDotNet47.dll"
$success = $false
$certStore = New-Object Chilkat.CertStore
# This opens the Current User certificate store on Windows,
# On MacOS and iOS it opens the default Keychain.
$readOnly = $false
$success = $certStore.OpenCurrentUserStore($readOnly)
if ($success -eq $false) {
$($certStore.LastErrorText)
exit
}
$cert = New-Object Chilkat.Cert
$numCerts = $certStore.NumCertificates
$i = 0
while (($i -lt $numCerts)) {
# Load the cert object with the Nth certificate.
$certStore.GetCert($i,$cert)
$([string]$i + ": " + $cert.SubjectCN)
$i = $i + 1
}