Advertisement
Guest User

Untitled

a guest
Aug 20th, 2014
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. Set-Location -Path WSMan:localhostService;
  2. Set-Item -Path .CertificateThumbprint -Value 'THUMBPRINT';
  3.  
  4. $yourCred = Get-Credential domainaccount
  5. $yourServer = "your.server.fqdn"
  6.  
  7. $LatestThumb = Invoke-Command -ComputerName $yourServer `
  8. -Credential $yourCred `
  9. -ScriptBlock {
  10. Get-ChildItem -Path Cert:LocalMachineMy |
  11. Sort-Object -Property NotAfter |
  12. Select-Object -Last 1 -ExpandProperty Thumbprint
  13. }
  14.  
  15. Set-WSManInstance -ResourceURI winrm/config/Listener `
  16. -SelectorSet @{Address="*";Transport="HTTPS"} `
  17. -ComputerName $yourServer `
  18. -Credential $yourCred `
  19. -ValueSet @{CertificateThumbprint=$LatestThumb}
  20.  
  21. Invoke-Command -ComputerName $yourServer `
  22. -Credential $yourCred `
  23. -ScriptBlock { Restart-Service -Force -Name WinRM }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement