Permalink
Find file Copy path
77ce9b7 Oct 26, 2018
1 contributor

Users who have contributed to this file

14 lines (12 sloc) 733 Bytes
#Create self-signed certificate and export pfx and cer files
$PfxFilePath = 'mikkelhmKeys.pfx'
$CerFilePath = 'mikkelhmKeys.cer'
$DNSName = 'dnsname-can-be-whatever'
$Password = 'password'
$StoreLocation = 'CurrentUser' #be aware that LocalMachine requires elevated privileges
$CertBeginDate = Get-Date
$CertExpiryDate = $CertBeginDate.AddYears(1)
$SecStringPw = ConvertTo-SecureString -String $Password -Force -AsPlainText
$Cert = New-SelfSignedCertificate -DnsName $DNSName -CertStoreLocation "cert:\$StoreLocation\My" -NotBefore $CertBeginDate -NotAfter $CertExpiryDate -KeySpec Signature
Export-PfxCertificate -cert $Cert -FilePath $PFXFilePath -Password $SecStringPw
Export-Certificate -cert $Cert -FilePath $CerFilePath