Created
November 26, 2024 17:37
-
-
Save senorsmile/cd0f7d07276a9768e3778b21c2f742c4 to your computer and use it in GitHub Desktop.
Powershell script to enable winrm
This file contains hidden or 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
| # 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