Guest User

Untitled

a guest
Jun 25th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. param($result)
  2.  
  3. if ($result.IsSuccess -eq $true)
  4. {
  5. # Convert CNG certificate storage to CSP (for Exchange 2013)
  6. $tempfile = "$env:TEMP\CertifyTemp.pfx"
  7. $pfx = get-pfxcertificate -filepath $result.ManagedItem.CertificatePath
  8. certutil -f -p Certify -exportpfx $pfx.SerialNumber $tempfile
  9. certutil -delstore my $pfx.SerialNumber
  10. certutil -p Certify -csp "Microsoft RSA SChannel Cryptographic Provider" -importpfx $tempfile
  11. remove-item $tempfile
  12.  
  13. # Enable certificate for Exchange 2013 / 2016 services on same server
  14. Add-PSSnapIn *exchange*
  15. Enable-ExchangeCertificate -Thumbprint $result.ManagedItem.CertificateThumbprintHash -Services POP,IMAP,SMTP,IIS
  16.  
  17. # update Remote Desktop Server Certificate
  18. $rdpWmiPath = (Get-WmiObject -class "Win32_TSGeneralSetting" -Namespace root\cimv2\terminalservices -Filter "TerminalName='RDP-tcp'").__path
  19. $certHash = $result.ManagedItem.CertificateThumbprintHash
  20. Set-WmiInstance -Path $rdpWmiPath -argument @{SSLCertificateSHA1Hash="$certHash"}
  21. }
  22. else
  23. {
  24. Write-Output "An error occurred retrieving the TLS certificate..."
  25. }
Add Comment
Please, Sign In to add comment