我有一个UCCE环境,上面安装了8台Windows服务器和4台CUCM服务器(Linux(。 我需要从所有8个Windows服务器和4个CUCM服务器导出所有证书。
法典:
dir cert:localmachinemy | Where-Object { $_.hasPrivateKey } | Foreach-Object { [system.IO.file]::WriteAllBytes("c:$($_.Subject).cer", ($_.Export('CER', 'secret')) ) }
我无法从远程 Windows 服务器导出证书,我尝试了以下代码:
$Srv = "remoteserver.com"
$Certs = Invoke-Command -Credential $cred -Computername $Srv -Scriptblock {Get-ChildItem "Cert:LocalMachineMy"}
使用$_.
访问 where-object 和 foreach-object cmdlet 中的当前对象。
Powershell还有一个pkiclient模块,你可以在其中使用export-certificate
cmdlet