How to Enable WinRM (Windows Remote Management) Using PowerShell?

WinRM is a powerful tool that allows you to manage and configure remote Windows computers securely. In this tutorial, I will explain how to enable WinRM (Windows Remote Management) using PowerShell. Let me show you examples.

What is WinRM?

WinRM is a protocol that allows you to interact with remote computers using a set of standard APIs. It leverages the WS-Management protocol to facilitate remote management and automation tasks. With WinRM, you can execute commands and scripts and even manage Windows services on remote machines.

Note: You should have administrative privileges on the local and remote computers.

Now, let me show you step-by-step how to enable WinRM using PowerShell.

Enable WinRM Using PowerShell

Now, let’s walk through the steps to enable WinRM using PowerShell.

Step 1: Open PowerShell as Administrator

To get started, open PowerShell as an administrator. This is very important because enabling WinRM requires elevated privileges. To do this:

  1. Press the Windows key and type “PowerShell”
  2. Right-click on “Windows PowerShell” and select “Run as administrator”

Step 2: Check the Current WinRM Status

Before enabling WinRM, it’s a good idea to check its current status. Run the following command:

winrm quickconfig

If WinRM is already enabled, you will see a message indicating that WinRM is already running on this machine. If WinRM is not enabled, you will see a prompt asking if you want to enable it.

I executed the above PowerShell script in my local system, and you can see the exact output in the screenshot below.

Enable WinRM Using PowerShell

Check out Enable Remote Desktop Using PowerShell

Step 3: Enable WinRM

If WinRM is not enabled, you can enable it using the following command:

Enable-PSRemoting -Force

The Enable-PSRemoting cmdlet configures the computer to receive PowerShell remote commands sent using the WS-Management technology. The -Force parameter skips the confirmation prompt.

Alternatively, you can use the winrm quickconfig command to enable WinRM and set up the default configuration for remote management:

winrm quickconfig

This command will prompt you to enable WinRM if it is not already enabled.

Step 4: Configure WinRM Listener

By default, WinRM listens on HTTP port 5985. However, you can configure it to listen on HTTPS port 5986 for added security. To configure the WinRM listener, use the following command:

winrm set winrm/config/service '@{EnableCompatibilityHttpListener="true"}'

This command enables the compatibility HTTP listener, allowing WinRM to accept both HTTP and HTTPS connections.

Check out Uninstall a Program with PowerShell

Step 5: Set WinRM Service to Start Automatically

To ensure that WinRM starts automatically when your computer boots up, set the WinRM service startup type to “Automatic” using the following command:

Set-Service -Name WinRM -StartupType Automatic

Step 6: Test WinRM Connectivity

Once you have enabled and configured WinRM, it’s crucial to test the connectivity. Let’s say you want to test the WinRM connectivity from your local computer (e.g., named “JohnsLaptop”) to a remote computer (e.g., named “SarahsDesktop”). Run the following command:

Test-WSMan SarahsDesktop

If the test is successful, you will see output similar to the following:

wsmid           : http://schemas.dmtf.org/wbem/wsman/identity/1/wsmanidentity.xsd
ProtocolVersion : http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd
ProductVendor   : Microsoft Corporation
ProductVersion  : OS: 0.0.0 SP: 0.0 Stack: 3.0

This confirms that WinRM is enabled and accessible on the remote computer.

Check out Uninstall Microsoft Edge Using PowerShell

Troubleshooting WinRM Connection Issues

If you encounter issues while connecting to a remote computer using WinRM, here are a few troubleshooting tips:

  1. Verify that WinRM is enabled on both the local and remote computers by running winrm quickconfig.
  2. Check the firewall settings on the remote computer. Ensure that the necessary ports (5985 for HTTP and 5986 for HTTPS) are open.
  3. Ensure that the remote computer is accessible over the network and that there are no connectivity issues.
  4. Verify that the user account you are using has the necessary permissions to access the remote computer.
  5. Check the group policies that may be configuring WinRM on the remote computer. Run the following command from an administrative command prompt:
   gpresult /H C:\GPO_Report.html

Open the generated HTML report and search for “WinRM” to identify the relevant group policies.

Conclusion

In this tutorial, we covered the steps to enable WinRM using PowerShell. We started by understanding what WinRM is and its importance in remote management. We then walked through the process of enabling WinRM, configuring the listener, setting the service startup type, and testing the connectivity. Additionally, we provided troubleshooting tips for common WinRM connection issues.

Let me know in the comment below if you face any issues while enabling WinRM using PowerShell.

You may also like:

100 PowerShell cmdlets download free

100 POWERSHELL CMDLETS E-BOOK

FREE Download an eBook that contains 100 PowerShell cmdlets with complete script and examples.