Friday, April 8, 2011

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.

From stackoverflow
  • 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() }
    
    Brian Adams : Great, that worked and gets me closer to solving the problem. I'll do some researching before asking about the 64 bit version of CAPICOM.

0 comments:

Post a Comment

Note: Only a member of this blog may post a comment.