Search code examples
powershellcertificatecapicom

How can I access Certificate ExtendedProperties using powershell?


If you open the properties window of a certificate in the certificate manager in windows you will see both a friendlyname and description field. I'm trying to get to the description field programatically via powershell.

When accessing the certificates via powershell's certificate provider cert: you get an object that only exposes the FriendlyName as Name.

As far as I can tell, this is all a wrapper to the CAPICOM APIs. Neither the description or the get_extendedproperties method are exposed.

How can I access the description field problematically via powershell? Please note that I tried to simply do

$store = new-object -com "CAPICOM.Store" 

to use the CAPICOM api directly ala This Link, but I get a 80040154 error on my 64bit Win2K8 box.


Solution

  • Open x86 Powershell instead of x64. This should get you started:

    $store = new-object -com "CAPICOM.Store"
    $store.Open(2, "CA", 1)
    $store | fl *
    $store.Certificates
    $store.Certificates | %{ $_.display() }
    $store.Certificates | %{ $_.extendedproperties() }