(PowerShell) Find a Certificate in the "Other People" Windows Certificate Store
Demonstrates how to open the "Current User --> Other People" Windows certificate store, and locates a certificate matching an email address. Note: This example requires Chilkat v10.1.2 or greater.
Add-Type -Path "C:\chilkat\ChilkatDotNet47-x64\ChilkatDotNet47.dll"
$certStore = New-Object Chilkat.CertStore
# The "AddressBook" is the "Other People" certificate store as shown in certmgr.msc
$readOnly = $true
$success = $certStore.OpenWindowsStore("CurrentUser","AddressBook",$readOnly)
if ($success -ne $true) {
$($certStore.LastErrorText)
exit
}
# Find the certificate for the email address:
$jsonE = New-Object Chilkat.JsonObject
$jsonE.UpdateString("email","joe@example.com")
$cert = New-Object Chilkat.Cert
$success = $certStore.FindCert($jsonE,$cert)
if ($success -eq $false) {
$($certStore.LastErrorText)
exit
}
$("Found certificate: " + $cert.SubjectDN)
|