I have a UCCE environment where there are 8 Windows servers and 4 CUCM servers(Linux) installed on it. I need to export all the certificates from all the 8 Windows servers and 4 CUCM servers.
Code:
dir cert:\localmachine\my | Where-Object { $_.hasPrivateKey } | Foreach-Object { [system.IO.file]::WriteAllBytes("c:\$($_.Subject).cer", ($_.Export('CER', 'secret')) ) }
I wasn't able to export a certificate from remote Windows servers, I tried below code:
$Srv = "remoteserver.com"
$Certs = Invoke-Command -Credential $cred -Computername $Srv -Scriptblock {Get-ChildItem "Cert:\LocalMachine\My"}