繁体   English   中英

使用PowerShell从IIS导出证书

[英]Export certificate from IIS using PowerShell

如何使用PowerShell从IIS 7导出自签名证书?

dir cert:\localmachine\my | Where-Object { $_.hasPrivateKey } |   Foreach-Object { [system.IO.file]::WriteAllBytes("c:\$($_.Subject).pfx",     ($_.Export('PFX', 'secret')) ) }

来源: 使用私钥导出证书

这会将所有证书导出到C:\\

您可以通过运行来检查您拥有的证书:

dir cert:\localmachine\my

值得注意的是,当我尝试导出我的根证书时,由于unicode中的外语字符无效,我不得不使用Thumbprint作为文件名而不是Subject。 这有效:

dir cert:\localmachine\root |
Foreach-Object { [system.IO.file]::WriteAllBytes("c:\temp\$($_.Thumbprint).cer",     ($_.Export('CERT', 'secret')) ) }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM