Sample code for 30+ languages & platforms
PowerShell

Load Certificate from Smartcard in Reader (or from USB Token)

See more Certificates Examples

Demonstrates how to load the certificate that is on the smartcard currently inserted into the smartcard reader. (Also can load the smartcard on a USB token.)

Chilkat PowerShell Downloads

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

$success = $false

$cert = New-Object Chilkat.Cert

# If you know the smart card PIN, set it prior to loading from the smartcard/USB token.
$cert.SmartCardPin = "12345678"

# Pass an empty string to allow Chilkat to discover the smart card or USB token automatically.
$success = $cert.LoadFromSmartcard("")
if ($success -eq $false) {
    $($cert.LastErrorText)
    exit
}

$("Cert loaded from smartcard: " + $cert.SubjectCN)