Sample code for 30+ languages & platforms
PowerShell

Load PFX (PKCS#12) and List Certificates

See more Certificates Examples

Loads a PFX file (.pfx, .p12) and iterates over the certificates found within.

Chilkat PowerShell Downloads

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

$success = $false

$certStore = New-Object Chilkat.CertStore

$pfxPath = "/Users/chilkat/testData/pfx/chilkat_ssl.pfx"
$pfxPassword = "test"
$success = $certStore.LoadPfxFile($pfxPath,$pfxPassword)
if ($success -ne $true) {
    $($certStore.LastErrorText)
    exit
}

$numCerts = $certStore.NumCertificates

$("PFX contains " + $numCerts + " certificates")

$cert = New-Object Chilkat.Cert
$i = 0
while ($i -lt $numCerts) {
    $certStore.GetCert($i,$cert)

    $([string]$i + ": (Common Name) " + $cert.SubjectCN)
    $([string]$i + ": (Serial Number) " + $cert.SerialNumber)
    $([string]$i + ": (Distinguished Name) " + $cert.SubjectDN)

    $i = $i + 1
}