Finding Code Signing Certificates

by Oct 24, 2011

To digitally sign PowerShell scripts, you need a certificate with the purpose "CodeSigning". Here is how you find out which code signing certificates are available to you – if any:

dir cert:\CurrentUser\my -CodeSigningCert

If this line does not return a result, then you currently have no code signing certificates installed.

If you have more than one code signing certificate listed, use Where-Object to pick the one you want to use. The next line gets you the certificate that was issued to "Henry" and stores it in a variable $cert:

$cert = dir cert:\CurrentUser\my -CodeSigningCert | Where-Object { $_.Subject -like '*Henry*' }

To view all certificate properties, use Select-Object:

$cert | Select-Object -Property *

Twitter This Tip!
ReTweet this Tip!