5

In quite a few places the command for changing the port winrm listens on look like this:

winrm set winrm/config/Listener?Address=*+Transport=HTTP @{Port="8888"}

However this does not work for me. The error I'm getting is:

Error: Invalid use of command line. Type "winrm -?" for help.

Obviously, internet can't be wrong, so that's me doing something incorrectly. The question is, how to do this correctly?

Andrew Savinykh
  • 526
  • 2
  • 7
  • 21

1 Answers1

10
  1. Open a PowerShell window with administrative privileges.
  2. Run dir WSMan:\localhost\listener\*\Port and check the Value parameter to see what you're currently listening on.
  3. If you'd like to change it, run Set-Item WSMan:\localhost\listener\*\Port 8888

If you'd still like to do it with winrm, you need to modify your command to the following --

winrm set winrm/config/Listener?Address=*+Transport=HTTP '@{Port="8888"}'
pk.
  • 6,451
  • 2
  • 42
  • 63
  • You might need to restart the WinRM service afterwards for the change to take effect. +1 – Ryan Ries Apr 30 '12 at 16:41
  • does "Set-Item" has any advantage over "winrm set"? – Talespin_Kit Feb 21 '14 at 11:06
  • I believe this Microsoft blog post would supplement this answer nicely by adding more alternatives and client-side configuration https://blogs.technet.microsoft.com/christwe/2012/06/20/what-port-does-powershell-remoting-use/ – wandersick Sep 21 '19 at 08:10