[Powershell] Export Self-Signed Certificate

 

$cert = New-SelfSignedCertificate -DnsName yourdomain.cloudapp.net -CertStoreLocation “cert:\LocalMachine\My”

$password = ConvertTo-SecureString -String “Password@1234” -Force -AsPlainText

#Generate .pfx
Export-PfxCertificate -Cert $cert -FilePath “.\my-cert-file.pfx” -Password $password

#Export to .cer format
Export-Certificate -Type CERT -Cert $cert -FilePath .\my-cert-file.cer

Leave a Comment