Skip to content

Instantly share code, notes, and snippets.

@jeffpatton1971
Created February 4, 2017 15:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeffpatton1971/2321f0db8025e48ad8ec13c243153045 to your computer and use it in GitHub Desktop.
Save jeffpatton1971/2321f0db8025e48ad8ec13c243153045 to your computer and use it in GitHub Desktop.
This script will enable WinRM
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