Difference between revisions of "Powershell get certificates"
Jump to navigation
Jump to search
(Created page with " ``` $store = New-Object System.Security.Cryptography.X509Certificates.X509Store([System.Security.Cryptography.X509Certificates.StoreName]::My,"localmachine") $store.Open("Max...") |
|||
| Line 1: | Line 1: | ||
| + | ``` | ||
| + | $mypwd = ConvertTo-SecureString -String 'changeme' -Force -AsPlainText | ||
| + | gci -path cert:\localmachine\My\${THUMBPRINT} | Export-PfxCertificate -FilePath user.pfx -Password $mypwd | ||
| + | or | ||
| + | | Export-Certificate -Cert $cert -FilePath user.cer | ||
| + | ``` | ||
``` | ``` | ||
Revision as of 17:58, 21 September 2023
$mypwd = ConvertTo-SecureString -String 'changeme' -Force -AsPlainText
gci -path cert:\localmachine\My\${THUMBPRINT} | Export-PfxCertificate -FilePath user.pfx -Password $mypwd
or
| Export-Certificate -Cert $cert -FilePath user.cer
$store = New-Object System.Security.Cryptography.X509Certificates.X509Store([System.Security.Cryptography.X509Certificates.StoreName]::My,"localmachine")
$store.Open("MaxAllowed")
$cert = $store.Certificates | ?{$_.subject -match "^CN=asdasd"}
$cert.PrivateKey.ToXmlString($false)
$store.Close()