Export a certificate from IIS using PowerShell

How to export a self-signed certificate from IIS 7 using PowerShell?

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

Source: Private Key Certificate Export

This will export all your certificates to C:\ .

You can check what certificates you have:

 dir cert:\localmachine\my 
+8
source

It is worth noting that when I tried to export my root certificates, I had to use Thumbprint as the file name, not Subject, due to invalid foreign language characters in Unicode. It works:

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

Source: https://habr.com/ru/post/1387053/


All Articles