Friday, December 8, 2017

Extracting information from certificates on disk using PowerShell

One user wanted to determine some properties of a certificate that resides in a CER file on disk rather than in a certificate store. (If it were in a store, it would be accessible from the Cert:\ pseudo-drive.) I'm not sure if there's a cmdlet for this, but it's very easy to do with the X509Certificate2 class, since that has a constructor that takes a filename of a certificate on disk.

[System.Security.Cryptography.X509Certificates.X509Certificate2]::new('C:\path\to\cert.cer')

No comments:

Post a Comment