Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Set-Location -Path WSMan:localhostService;
- Set-Item -Path .CertificateThumbprint -Value 'THUMBPRINT';
- $yourCred = Get-Credential domainaccount
- $yourServer = "your.server.fqdn"
- $LatestThumb = Invoke-Command -ComputerName $yourServer `
- -Credential $yourCred `
- -ScriptBlock {
- Get-ChildItem -Path Cert:LocalMachineMy |
- Sort-Object -Property NotAfter |
- Select-Object -Last 1 -ExpandProperty Thumbprint
- }
- Set-WSManInstance -ResourceURI winrm/config/Listener `
- -SelectorSet @{Address="*";Transport="HTTPS"} `
- -ComputerName $yourServer `
- -Credential $yourCred `
- -ValueSet @{CertificateThumbprint=$LatestThumb}
- Invoke-Command -ComputerName $yourServer `
- -Credential $yourCred `
- -ScriptBlock { Restart-Service -Force -Name WinRM }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement