hel*_*one 4 .net c# powershell
我正在尝试使用powershell获得所有证书。当我在脚本下面将“ \ $ computer \ My”设置为存储位置时,我会返回用户证书。
当我设置“ \ $ computer \ root”时,它将返回根证书。如何获得用户证书和机器证书?
$computer='localhost';
$ro=[System.Security.Cryptography.X509Certificates.OpenFlags]"ReadOnly"
$lm=[System.Security.Cryptography.X509Certificates.StoreLocation]"LocalMachine"
$store=new-object System.Security.Cryptography.X509Certificates.X509Store("\\$computer\My",$lm)
$store.Open($ro)
$certificates=$store.Certificates
Run Code Online (Sandbox Code Playgroud)
dhc*_*cgn 15
有一个PSDrive Cert,其中包含CurrentUser和LocalMachine。
因此,这将为您获取所有证书:
Get-ChildItem Cert:\ -Recurse
Run Code Online (Sandbox Code Playgroud)
小智 6
特别是为了获取用户和本地计算机证书(仅限):
Get-ChildItem Cert:\LocalMachine\My | ft
Get-ChildItem Cert:\CurrentUser\My | ft
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
12442 次 |
| 最近记录: |