[英]Export certificate from IIS using PowerShell
dir cert:\localmachine\my | Where-Object { $_.hasPrivateKey } | Foreach-Object { [system.IO.file]::WriteAllBytes("c:\$($_.Subject).pfx", ($_.Export('PFX', 'secret')) ) }
Source: Exporting Certificate With Private Key 来源: 使用私钥导出证书
This will export all of your certificates into C:\\
. 这会将所有证书导出到
C:\\
。
You can check what certificates you have by running: 您可以通过运行来检查您拥有的证书:
dir cert:\localmachine\my
Worth noting that when I tried to export my root certificates, I had to use Thumbprint as the filename, not Subject, due to invalid foreign-language characters in the unicode. 值得注意的是,当我尝试导出我的根证书时,由于unicode中的外语字符无效,我不得不使用Thumbprint作为文件名而不是Subject。 This works:
这有效:
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.