Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Stop-Service -DisplayName "MailEnable*"
- $FileName = "C:\mypfx.pfx"
- $serverName = "CN=mail.xyzdomain.com"
- if (Test-Path $FileName)
- {
- Remove-Item $FileName
- }
- $mypwd = ConvertTo-SecureString -String "1234" -Force -AsPlainText
- $thumb = Get-ChildItem Cert:\LocalMachine\WebHosting `
- | where{$_.Subject -eq $serverName}
- $final = $thumb.Thumbprint
- Get-ChildItem -Path cert:\LocalMachine\WebHosting\$final | Export-PfxCertificate -FilePath $FileName -Password $mypwd
- try {
- Get-ChildItem Cert:\LocalMachine\My | Where-Object {$_.Subject -eq $serverName} | Remove-Item
- } catch {}
- Import-PfxCertificate -FilePath $FileName -CertStoreLocation Cert:\LocalMachine\My -Password $mypwd
- if (Test-Path $FileName)
- {
- Remove-Item $FileName
- }
- Start-Service -DisplayName "MailEnable*"
Advertisement
Add Comment
Please, Sign In to add comment