Created
February 4, 2017 15:12
-
-
Save jeffpatton1971/2321f0db8025e48ad8ec13c243153045 to your computer and use it in GitHub Desktop.
This script will enable WinRM
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param | |
( | |
[string]$Hostname = $env:COMPUTERNAME | |
) | |
try | |
{ | |
$ErrorActionPreference = 'Stop'; | |
$CertificateThumbprint = (New-SelfSignedCertificate -DnsName $Hostname -CertStoreLocation Cert:\LocalMachine\My).Thumbprint; | |
New-WSManInstance -ResourceURI 'winrm/config/listener' -SelectorSet @{Address='*';Transport='https'} -ValueSet @{Hostname=$Hostname;CertificateThumbprint=$CertificateThumbprint} | |
} | |
catch | |
{ | |
throw $_; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment