0

Every resource I've found so far, such as this question, boils down to:

  1. Get the certificate as an X509Certificate2
  2. Cast the PrivateKey property to RSACryptoServiceProvider
  3. Do stuff involving CspKeyContainerInfo property on the private key

This works in PowerShell 5, but in PowerShell 7, the PrivateKey property is an RSACng, not an RSACryptoServiceProvider, and so step 2 doesn't work.

Mark Raymond
  • 906
  • 8
  • 22

1 Answers1

0

FYI, PrivateKey was deprecated. You are now required to use the GetRSAPrivateKey extension method.

I cannot find any documentation, but it appears that .Net Framework used to return an RSA that also implemented RSACryptoServiceProvider which is where we could get the CspKeyContainerInfo, but now we are required to grab the key RSA derived type RSACng which is returned by the extension method. From here you can grab properties like the $cert.Key.UniqueName