Windows Remote Management (WinRM) lets an administrator run PowerShell commands on a server from another machine. It listens on two ports: 5985 for HTTP and 5986 for HTTPS. On a modern Windows Server it is switched on by default, which is why WinRM ports 5985 and 5986 often show up as open on servers where nobody remembers enabling anything. Inside the office that is usually fine. Reachable from the internet, it is one more door for password guessing, and a powerful one if the guess works.
This post explains what the two ports do, what the real risk is, and how to close them to the internet without breaking the tools that depend on them.
What WinRM is, and why it is already on
WinRM is Microsoft’s implementation of the WS-Management protocol. PowerShell Remoting runs over it: instead of opening a Remote Desktop session, an administrator types Enter-PSSession or Invoke-Command and the commands run on the server. Microsoft enables PowerShell Remoting by default on Windows Server 2012 R2 and later (Microsoft), and Windows tools rely on it: Server Manager uses it to manage the server, and so does Windows Admin Center. Some backup and monitoring tools, and automation tools such as Ansible, use it too.
By default only members of the Administrators group may connect. Windows Firewall’s built-in rules accept WinRM from any address on Domain and Private networks, and only from the same subnet on Public networks.
Port 5985 and port 5986: what is the difference?
Port 5985 carries WinRM over HTTP. That sounds like plain text, but it is not in normal use. Sign-in uses Kerberos (in a domain) or NTLM (in a workgroup, as on most small-office servers), and neither sends the password itself across the network. After that first step, Microsoft’s documentation is explicit: “Regardless of the transport protocol used (HTTP or HTTPS), WinRM always encrypts all PowerShell remoting communication after initial authentication.” The one setup that really is cleartext is Basic authentication combined with the AllowUnencrypted setting, and both are off by default.
Port 5986 carries WinRM over HTTPS, wrapped in TLS. Its extra value is that the server proves its identity with a certificate, which NTLM on its own cannot do. It needs a certificate set up on the server, so it is less common on small-office machines.
The risk of an exposed 5985 is therefore password guessing, not eavesdropping: anyone on the internet can try usernames and passwords against it.
Why exposed WinRM ports are dangerous
Bots that guess Remote Desktop passwords also try WinRM. Each failed attempt is logged as a failed sign-in (event 4625), just like an RDP attack, and the same weak or reused password opens both doors. A successful guess on an admin account gives the attacker a command line on your server, with no screen and nothing for a member of staff to notice. From there they can:
- Run anything: download and start ransomware, create a back-door admin account, switch off Windows Defender.
- Take data: copy client files and the Tally data folder.
- Move on: use the server to reach other machines in the office.
- Cover tracks: clear event logs and change audit settings.
Check what your server is doing
Do not use winrm quickconfig to check. Despite the name, it configures WinRM: it starts the service, creates a listener and adds a firewall exception (Microsoft). To look without changing anything, in an elevated PowerShell window:
Get-Service WinRM
winrm enumerate winrm/config/listener
winrm get winrm/config/service
The first line shows whether the service is running, the second which listeners exist (HTTP on 5985, HTTPS on 5986), and the third the service settings. In that last output, AllowUnencrypted should be false and, under Auth, Basic should be false.
Then check whether the internet can reach the ports. Behind an office router, look at its port-forwarding page for 5985 or 5986; on a cloud server, look at the security group. Finally, from outside the office (a laptop on a phone hotspot), Test-NetConnection 203.0.113.10 -Port 5985 with your public IP should report TcpTestSucceeded : False.
How to fix it
The safe default is to keep WinRM working inside the office and refuse it from everywhere else.
- Close it at the router or security group. There is no good reason to forward 5985 or 5986 from the internet. Delete any such forward.
- Scope the Windows Firewall rules to the office network. In an elevated PowerShell window, this limits the built-in WinRM rules to your local subnet:
Get-NetFirewallRule -DisplayGroup "Windows Remote Management" -Direction Inbound | Set-NetFirewallRule -RemoteAddress LocalSubnet
If someone manages the server from another known network, add that address range afterLocalSubnet, separated by a comma. - Bring remote administrators in through a private connection. An IT vendor who manages the server from their own office should connect through a VPN or Prixl Guard Secure Access first, then use WinRM over that private link.
- Keep Basic authentication and unencrypted traffic off, and use HTTPS on 5986 with a proper certificate if WinRM must cross networks you do not control.
- Record what remote sessions do. Turn on PowerShell script block logging, so commands run over WinRM are written to the PowerShell log.
Should you switch WinRM off completely?
Usually not on a server. Stopping the service breaks Server Manager’s management of the server, Windows Admin Center, and any backup, monitoring or vendor tool that uses PowerShell Remoting, and those failures tend to surface weeks later as a mystery. Once the ports are closed to the internet, an internal-only WinRM is a small risk. If you are sure nothing uses it, ask your IT vendor to confirm and then, from an elevated PowerShell window:
Stop-Service WinRM
Set-Service WinRM -StartupType Disabled
To undo it, run Set-Service WinRM -StartupType Automatic and then Start-Service WinRM.
How Prixl Warden handles WinRM
Warden’s security audit reads the server’s Windows Firewall rules. Its “WinRM HTTP (5985)”, “WinRM HTTPS (5986)” and “WinRM Internet Exposure” checks flag an enabled inbound rule that allows these ports from any address. Warden cannot see your router, so behind an office router the port-forward still decides whether the internet can reach them.
On a paid plan, the Hardening tab offers two kinds of fix:
- “WinRM Internet Exposure” (a safe fix). Restricts ports 5985 and 5986 to your local network, with a “Restrict mode” of “LAN only (no Guard access)” or “LAN + Guard”, and blocks them from internet addresses. Remote management inside the office keeps working. The Open Ports tab offers the same “LAN only” and “LAN + Guard” buttons (see restricting risky ports).
- “Port 5985 Open” and “Port 5986 Open” (risky fixes). Disable the inbound allow rules for that port altogether. Warden labels them risky and warns before applying, for 5985: “WARNING: PowerShell remoting and remote management tools will stop working.”
Any applied fix can be reverted from the “Previously Applied” list. Warden also watches the server’s sign-in events, so password-guessing against WinRM appears in your alerts the same way an attack on Remote Desktop does.
To see which ports your server has open right now, start your 30-day free trial of Prixl Warden. The trial runs the full audit; the one-click fixes need a paid plan.
