In many cases we want to create a self-signed certificate from PowerShell scripts
Create Certificate and Export Certificate by setting password
- Get
the date details and save in variable $todaydt = Get-Date
- Set
number of years of certificate expiry $3years = $todaydt.AddYears(3)
- Now run
this command to create certificate without expiry date “New-SelfSignedCertificate
-DnsName ADFSQAWIN19.ADHIDQA.com
-CertStoreLocation cert:\LocalMachine\My”
- Run
this command to create certificate with expiry date “New-SelfSignedCertificate
-dnsname ADFSQAWIN19.ADHIDQA.com -notafter $3years -CertStoreLocation
cert:\LocalMachine\My”
- Save password as plain text “$CertPassword =
ConvertTo-SecureString -String ‘<my password>’ -Force –AsPlainText”
- Export with this command “Export-PfxCertificate -Cert
cert:\LocalMachine\My\<Certificate ID which you will get after create
certificate> -FilePath C:\test.pfx -Password $CertPassword”
Comments
Post a Comment