PowerShell is an incredible tool for IT professionals. But, if you don’t have Windows Remote Management (WinRM) enabled, you could be limiting the effectiveness of your PowerShell scripts and running into expected errors. In this guide, I’ll show you several methods you can use to configure WinRM on your Windows devices.
Test if WinRM is enabled
Before we start configuring WinRM, it’s a good idea to check to see if it’s not already enabled on your devices. To test if WinRM is enabled, run Test-WSMan
from a PowerShell window. Here’s an example.
In this guide, I’m using PowerShell 7.x from an elevated command prompt. These commands should also work in Windows PowerShell, though you can get different results if you are using a mixture of Windows PowerShell and PowerShell 7.x on your devices.
Test-WSMan -ComputerName “computer_name”
I ran this command on a few different computers, two with WinRM enabled and one with it disabled, so you can see the different results. This command is great if you’re like me and your biggest pet peeve is doing extra work for no reason.
Enable WinRM with the WinRM quickconfig command
The fastest and easiest way to enable WinRM is with the WinRM quickconfig
command. WinRM quickconfig
automatically configures several settings, such as WinRM listeners, inbound firewall rules, and the Windows Remote Management (WS-Management) service, to ensure WinRM is working properly.
In this screenshot, you see that the command walked me through several prompts, enabling the various settings to ensure WinRM is properly configured. Now if we rerun the test from the previous section, this device should now pass it.
While this command is very fast and easy to use, it does have a couple of drawbacks. First, since WinRM isn’t already enabled on the target devices, you’ll need to run the command locally on the client or run a remote PowerShell session with something like PsExec to run the command. Second, this method is only quick if you need to enable WinRM on a few machines. If you need to enable WinRM on dozens of devices or across an entire domain, you’ll want to use one of the methods discussed below.
Enable WinRM with Group Policy
Group Policy is a great option for enabling WinRM in a domain environment. With Group Policy, you can quickly enable WinRM, configure the WinRM service, and set your firewall rules. Group Policy also has several other features you can configure to customize your WinRM implementation.
Here’s how to enable WinRM with Group Policy and set the IP filters.
Open your Group Policy Management Console.
Right-click on an OU you want to apply the policy to, then click Create a GPO in this Domain, and Link it here.
Name the policy Enable WinRM, then click OK.
Right-click on the new GPO and click Edit.
Expand Computer Configuration > Policies > Administrative Templates > Windows Components > Windows Remote Management (WinRM) > WinRM Service.
Locate Allow remote server management through WinRM, and double-click it to edit the setting.
Select Enabled.
Enter a range of IP addresses in the IPv4 and IPv6 filter boxes or add an asterisk to allow all IP addresses.
Next, let’s configure the WinRM service to start automatically.
Navigate to Computer > Configurations > Preferences > Control Panel Settings > Services.
Right-click in the Services window, then click New > Service.
Change the Startup to Automatic (Delayed Start).
Click the ellipsis button next to the Service name field.
Find and select the service name WinRM.
Select Start Service from the service action menu, then click Apply and OK.
Lastly, we need to configure the firewall rules.
Expand Computer Configuration > Policies > Windows Settings > Security Settings > Windows Defender Firewall with Advanced Security > Windows Defender Firewall with Advanced Security.
Right-click on Inbound Rules, then click New Rule.
Select Predefined, then select Windows Remote Management from the drop-down menu.
Click Next.
Uncheck the public profile rule.
Click Next.
Select Allow the connection, then click Finish.
With the Group Policy Object in place, any devices assigned that GPO will automatically have the necessary Windows Remote Management settings configured.
Enable WinRM with PDQ Deploy
If Group Policy isn’t an option for your environment, you can use PDQ Deploy to push out the WinRM quickconfig
command to all your managed devices and Windows servers. To ensure we don’t interrupt any users, we’ll use the -quiet
parameter to run the command silently.
In PDQ Deploy, click New Package.
Add a name like Enable WinRM to your package.
Click New Step > PowerShell.
Add the command
WinRM quickconfig -quiet
to the PowerShell window.Click Save.
Your WinRM package is ready to deploy to as many or as few devices as you need. This is a great way to limit the number of devices you enable WinRM on.
Enable WinRM with PDQ Connect
Enabling WinRM with PDQ Connect is a similar process to enabling it with PDQ Deploy, but Connect gives you the ability to deploy the package to remote devices. To create a WinRM enablement package in Connect:
Click the Packages tab.
Click Create package.
Add a package name.
Click the down arrow next to Add install step, then click Add script step.
In the PowerShell window, enter the command
WinRM quickconfig -quiet
.When you’re ready, click Save to save the package.
To deploy the package:
In the Packages tab, locate and select the package you just created, then click Deploy.
Add your target devices or groups by searching for them in the Search devices and groups field.
When you’re ready, click Deploy.
Keep in mind that WinRM doesn’t let you run commands across the internet to remote devices. You’ll still be limited to running commands against computers that are reachable through your network. WinRM is pretty cool, but not quite that cool.
Easily run PowerShell scripts on remote devices
Need to run your awesome PowerShell scripts on remote devices? PDQ Connect can easily execute PowerShell scripts on any managed device with an active internet connection.