How can I access Certificate ExtendedProperties using powershell?

て烟熏妆下的殇ゞ 提交于 2019-12-11 09:53:29

问题


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.


回答1:


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() }


来源:https://stackoverflow.com/questions/584819/how-can-i-access-certificate-extendedproperties-using-powershell

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!