I’ve been using a post-deployment script for a long time to export a separate PFX file with a password for a secondary application. Sometime in the past year or so, the script started throwing tons of errors (in the second line)… but it somehow still generates the certificate so I haven’t bothered to fix it much. I’m not really an expert on Powershell though, and I’m wondering if anyone knows a better way to do this? For what it’s worth I do know that you can add a password to the main certificate and then just copy that elsewhere, but that main certificate password broke some of my other integrations.
$pfx = get-pfxcertificate -filepath $result.ManagedItem.CertificatePath certutil -f -p Password -exportpfx $pfx.SerialNumber "C:\Users\xxxx\AppData\Roaming\xxxxxxxxxxxxxx\Certificate.pfx"
Errors that I get are all related to certutil: ERROR_NO_TOKEN, ERROR_INVALID_PARAMETER, etc.