Guest User

Untitled

a guest
Sep 21st, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. If(-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator"))
  2. {
  3. #build up the deploy arguments
  4. $arguments = "-file `"{0}`"" -f $script:MyInvocation.MyCommand.Path
  5.  
  6. # Start the new process
  7. Start-Process powershell.exe -Verb runas -ArgumentList $arguments
  8. exit
  9. }
  10. else
  11. {
  12. $dnsName = Read-Host "Type the dns name for the cert"
  13. $dnsName = $dnsName
  14. $pfx = new-SelfSignedCertificate -DnsName $dnsName -CertStoreLocation cert:\LocalMachine\My -Provider "Microsoft Strong Cryptographic Provider" -HashAlgorithm "SHA256"
  15. $friendlyName = "SelfSigned-" + $dnsName
  16. $pfx.FriendlyName = $friendlyName
  17. $store = new-object System.Security.Cryptography.X509Certificates.X509Store(
  18. [System.Security.Cryptography.X509Certificates.StoreName]::Root,
  19. "localmachine"
  20. )
  21. $store.open("MaxAllowed")
  22. $store.add($pfx)
  23. $store.close()
  24. Write-Host "Your certificate has been added to the Personal and Root stores successfully"
  25. }
  26.  
  27. Read-Host "Press any key to exit"
Advertisement
Add Comment
Please, Sign In to add comment