Sample code for 30+ languages & platforms
PowerShell

Windows Certificate Stores - Find Certificate by Common Name

See more Certificates Examples

Searches the Windows certificate stores for a certificate that matches the specified common name (CN).

Note: This example requires Chilkat v10.0.0 or greater.

Chilkat PowerShell Downloads

PowerShell
Add-Type -Path "C:\chilkat\ChilkatDotNet47-x64\ChilkatDotNet47.dll"

$success = $false

$cert = New-Object Chilkat.Cert
$success = $cert.LoadByCommonName("Chilkat Software, Inc.")
if ($success -eq $false) {
    $($cert.LastErrorText)
    exit
}

$($cert.SubjectDN)
$("Success.")