winrm (Windows Remote Management) is a command-line tool provided by Microsoft as part of the Windows Operating System. It allows for the administration of remote machines using the WS-Management protocol, enabling users to securely manage their servers and workstations from a distance. The tool can be used to initiate remote sessions, execute scripts and commands across networked machines, and access full management capabilities over a secure connection.


The general usage syntax of winrm is:


Where [OPERATION] could refer to different tasks like create, delete, invoke, etc., and [OPTIONS] include various command-line arguments depending on the operation being performed.


Here is a breakdown of commonly used flags and their implications:

  • -f, --format: Specify the format for output data; typical values are XML or JSON.
  • -u, --username: Username for authentication on the remote system.
  • -p, --password: Corresponding password for the username.
  • -t, --transport: Type of transport protocol to use; options include HTTP or HTTPS.
  • -verbosity: Provides detailed debug information, simple messages, or only critical errors. Values range from quiet to verbose.


  1. Establishing a Connection:

    winrm quickconfig

    This command configures the local machine for remote management.

  2. Executing a Remote Command:

    winrm invoke Create wmicimv2/Win32_Process -argumenttype:"CommandLine='ipconfig /all'"

    Runs ipconfig /all on the remote system.

  3. Setting Up Listener:

    winrm create winrm/config/listener?Address=*+Transport=HTTP

    Creates an HTTP listener to accept requests on any IP associated with the machine.

Common Issues

  • Authentication Failures: Ensure credentials are correct and that remote management is enabled and configured on the target machine.
  • Firewall Blocks: Ensure that the firewall allows for the necessary ports (HTTP: 5985, HTTPS: 5986).
  • Encoding Issues: Problems might arise with character encoding; use flags to dictate encoding preferences where possible.


winrm can be combined with scripts or other CMD commands for robust remote management. For example:

for /f %i in (servers.txt) do winrm invoke Create wmicimv2/Win32_Process -r:http://%i:5985 -u:admin -p:password -argumenttype:"CommandLine='gpupdate /force'"

This loop reads server addresses from servers.txt and runs gpupdate /force across all listed servers using winrm.

  • powershell: Provides broader scripting capabilities and can invoke winrm within its scripts.
  • wmic: Another tool for Windows Management Instrumentation that can be used alongside or within winrm operations.

For detailed official documentation and additional resources, you can visit WinRM documentation on the Microsoft Documentation website.