Skip to content

Instantly share code, notes, and snippets.

@bahreex
Created December 13, 2017 07:13
Show Gist options
  • Save bahreex/526de42953a13ef0e3f3af093cff6a74 to your computer and use it in GitHub Desktop.
Save bahreex/526de42953a13ef0e3f3af093cff6a74 to your computer and use it in GitHub Desktop.
param($DNSName)
Enable-PSRemoting -Force
New-NetFirewallRule -Name 'WinRM HTTPS' -DisplayName 'WinRM HTTPS' -Enabled True -Profile 'Any' -Action 'Allow' -Direction 'Inbound' -LocalPort 5986 -Protocol 'TCP'
$thumbprint = (New-SelfSignedCertificate -DnsName $DNSName -CertStoreLocation Cert:\LocalMachine\My).Thumbprint
$cmd = "winrm create winrm/config/Listener?Address=*+Transport=HTTPS @{Hostname=""$DNSName""; CertificateThumbprint=""$thumbprint""}"
cmd.exe /C $cmd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment