Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用PowerShell从IIS导出证书_Iis_Powershell - Fatal编程技术网

使用PowerShell从IIS导出证书

使用PowerShell从IIS导出证书,iis,powershell,Iis,Powershell,如何使用PowerShell从7导出自签名证书 dir cert:\localmachine\my | Where-Object { $_.hasPrivateKey } | Foreach-Object { [system.IO.file]::WriteAllBytes("c:\$($_.Subject).pfx", ($_.Export('PFX', 'secret')) ) } 资料来源: 这将把您的所有证书导出到C:\ 您可以通过运行以下命令来检查您拥有的证书: dir c

如何使用PowerShell从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中的外语字符无效,我不得不使用指纹作为文件名,而不是主题。这项工作:

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

谢谢,上面的代码运行得很好,但是我需要将证书导出为.cer而不是pfx-关于如何实现这一点有什么想法吗?发现以下内容将起作用-感谢您的帮助dir cert:\localmachine\my | Where Object{$\ hasprovatekey}Foreach Object{[system.IO.file]::writealbytes(“c:\shared\test\$($\ Subject.cer”,($\u.Export('CERT','secret'))我在尝试使用$\u.Subject时遇到“路径中的非法字符”错误,但$\u.Thumbprint有效。谢谢如何仅导出未过期的证书?