Sample code for 30+ languages & platforms
PowerShell Requires Chilkat v11.0.0+

Transition from Cert.ExportPrivateKey to Cert.GetPrivateKey

Provides instructions for replacing deprecated ExportPrivateKey method calls with GetPrivateKey.

Chilkat PowerShell Downloads

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

$success = $false

$cert = New-Object Chilkat.Cert

#  ------------------------------------------------------------------------
#  The ExportPrivateKey method is deprecated:

$privatekeyObj = $cert.ExportPrivateKey()
if ($cert.LastMethodSuccess -eq $false) {
    $($cert.LastErrorText)
    exit
}

#  ...
#  ...

#  ------------------------------------------------------------------------
#  Do the equivalent using GetPrivateKey.
#  Your application creates a new, empty PrivateKey object which is passed 
#  in the last argument and filled upon success.

$privatekeyOut = New-Object Chilkat.PrivateKey
$success = $cert.GetPrivateKey($privatekeyOut)
if ($success -eq $false) {
    $($cert.LastErrorText)
    exit
}