WinRM

From PC Savants Wiki
Revision as of 02:06, 3 January 2022 by Pcsavants (talk | contribs)
Jump to navigation Jump to search

Powershell Remoting
How to enable WinRM manually or with Group Policy
Enable-PSRemoting
1. Allow remote server management through WinRM Go to Computer Configuration > Policies > Administrative Templates > Windows Remote Management (WinRM) > WinRM Service.
Double-click the setting “Allow remote server management through WinRM”
Select Enable and type in “*” in for both IPv4 filter and IPv6 filter.
* If you don’t see Windows Remote Management in your Group Policy Editor, there is probably the WinRM admin template missing in your Active Directory.

2. Enable WinRM service
Go to Computer Configuration > Policies > Preferences > Control Panel Settings.
And right-click Services and choose New > Service.
Choose Automatic (Delayed Start) as startup type, pick WinRM as the service name, set Start service as the action.

3. Set up the Firewall rule
Go to Computer Configuration > Policies > Security Settings > Windows Firewall with Advanced Security.
And right-click Inbound Rules and start a New Rule
Select Predefined: option and choose Windows Remote Management from the list (not the one with compatible). Click Next.
Select the one for Domain and Private, and Allow the connection option at the next screen. And click Finish.
To reduce the exposure to this service we can remove the Private and only leave only Domain profile in place. Double-click the new rule we just created, go to Advanced tab and uncheck the Private option from the Profiles section.

You can scan the port 5985 on the remote computer to see if it responses, like below:
Test-NetConnection -ComputerName remote_computer -Port Port#
Oh, simply open a PowerShell session on the remote computer and see if it succeeds.
Enter-PSSession -ComputerName remote_computer