Extracting the Private Key from a PFX

Given the recent and on-going issues with OpenSSL I am looking for another way to extract the private key from a certificate PFX file. Is there a way to do this via powershell?

I don’t know of a way to do this with Microsoft’s built-in crypto APIs, but it looks like you can use some of BouncyCastle’s API to accomplish that. See Extract Private Key as String from PFX File for an example of this in C#. (DotNetUtilities.GetRsaKeyPair() and the AsymmetricCipherKeyPair / PemWriter classes are from BouncyCastle, and the rest of the code is stuff from the .NET Framework.)