Skip to content

Instantly share code, notes, and snippets.

@senorsmile
Created November 26, 2024 17:37
Show Gist options
  • Select an option

  • Save senorsmile/cd0f7d07276a9768e3778b21c2f742c4 to your computer and use it in GitHub Desktop.

Select an option

Save senorsmile/cd0f7d07276a9768e3778b21c2f742c4 to your computer and use it in GitHub Desktop.
Powershell script to enable winrm
# Enables the WinRM service and sets up the HTTP listener
Enable-PSRemoting -Force
# Opens port 5985 for all profiles
$firewallParams = @{
Action = 'Allow'
Description = 'Inbound rule for Windows Remote Management via WS-Management. [TCP 5985]'
Direction = 'Inbound'
DisplayName = 'Windows Remote Management (HTTP-In)'
LocalPort = 5985
Profile = 'Any'
Protocol = 'TCP'
}
New-NetFirewallRule @firewallParams
# Allows local user accounts to be used with WinRM
# This can be ignored if using domain accounts
$tokenFilterParams = @{
Path = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System'
Name = 'LocalAccountTokenFilterPolicy'
Value = 1
PropertyType = 'DWORD'
Force = $true
}
New-ItemProperty @tokenFilterParams
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment