Tuesday, June 14, 2022

Generate cert with powershell

 Create a ps1 file and run it


 

$newCert = New-SelfSignedCertificate -DnsName "portalcm.local" -FriendlyName "Portal CM" -NotAfter (Get-Date).AddYears(5)


    $null = Export-PfxCertificate -Cert $newCert -FilePath .\Portal.pfx -Password (ConvertTo-SecureString -String "Test123!" -Force -AsPlainText)

    

    $null = [System.Convert]::ToBase64String([System.IO.File]::ReadAllBytes((Get-Item .\Portal.pfx))) | Out-File -Encoding ascii -NoNewline -Confirm -FilePath .\Portal.crt



No comments:

Post a Comment