Home › Topics › Windows Network Monitoring › WMI Monitoring

WMI Monitoring: the Ports, the Service, the Permissions and the Firewall Rule


Agentless Windows monitoring has one dependency, and it is the one administrators have been swearing at since 2001. WMI works on every Windows machine out of the box, it exposes almost everything worth knowing about the machine, and it fails for one of four reasons that this guide walks through in order: a port, a service, a permission or a repository. Read it once and the next "RPC server is unavailable" costs you two minutes instead of an afternoon.


In this guide

  • What WMI is, and what it stands for
  • What ports WMI uses, and the firewall rule
  • The WMI service: name, start, restart, enable
  • Permissions for agentless monitoring
  • Testing WMI before you blame the monitor
  • WMI namespaces, classes and the explorer
  • WMI filters in Group Policy
  • WMI health: repository, corruption, repair
  • Troubleshooting: symptom to cause
  • Where to go next

What Microsoft WMI is, what WMI stands for, and what it is used for


WMI stands for Windows Management Instrumentation. It is Microsoft's implementation of the WBEM standard: a service on every Windows machine that exposes the operating system, the hardware and many applications as a database of classes you can query with a SQL-like language. Win32_Service lists the services and their states; Win32_LogicalDisk has free space per volume; Win32_PerfFormattedData_PerfOS_Processor has CPU percent; Hyper-V, DNS, DHCP, IIS and SQL Server add classes of their own. A monitoring server queries those classes remotely over the network, which is what "agentless Windows monitoring over WMI" means: nothing is installed on the monitored machine, because the instrumentation is already there.


Microsoft has described WMI's remote protocol as legacy for years and offers WinRM (PowerShell remoting, ports 5985 and 5986) as the modern transport for the same classes. In practice, DCOM-based WMI remains on by default and is what most monitoring tools use, so this guide covers that path first.


What ports WMI uses, and the firewall rule to open


What port does WMI use? Two, and the second one is a range. Remote WMI runs over DCOM, which means RPC: the monitoring server first connects to TCP 135 (the RPC endpoint mapper) on the target, which answers with a second port from the dynamic RPC range, TCP 49152 to 65535 on Windows Vista and later (1024 to 5000 on older systems), and the actual WMI conversation happens on that second port. A firewall rule that opens 135 alone will produce the famous "RPC server is unavailable" error, because the second connection is refused.


PortDirectionPurpose
TCP 135Monitor → targetRPC endpoint mapper: "which port is WMI on?"
TCP 49152–65535 (dynamic RPC range)Monitor → targetThe WMI session itself; one port chosen per connection
TCP 5985 / 5986Monitor → targetWinRM over HTTP / HTTPS, the alternative transport for the same classes

On the target, the simplest correct firewall change is to enable the predefined rule group Windows Management Instrumentation (WMI) in Windows Defender Firewall, which opens 135 and the dynamic range for the WMI service only. If a network firewall sits between the monitor and the target and cannot follow the RPC negotiation, fix the dynamic range to something narrow with netsh int ipv4 set dynamicport tcp start=50000 num=255 on the target and open that range, or switch the monitor to WinRM. WMI port firewall problems are the first thing to rule out, not the last.


The WMI service: name, how to start, restart and enable it


The WMI service name is Winmgmt, displayed as "Windows Management Instrumentation". It is set to start automatically and almost never needs attention, but when it does: net start winmgmt starts it, Restart-Service winmgmt -Force restarts it (and the services that depend on it, which include the firewall and IP Helper, so do it in a window), and if someone has disabled it, Set-Service winmgmt -StartupType Automatic enables it again. Remote WMI also needs the Remote Procedure Call (RPC) and DCOM Server Process Launcher services, which are always running on a healthy system. A separate service, the WMI Performance Adapter (wmiApSrv), starts on demand to serve performance-counter classes and stops again a few minutes later; the "entered the stopped state" events it writes are normal and not a fault.


Permissions for agentless WMI monitoring


A member of the local Administrators group can query everything, and most sites start there. The least-privilege alternative for a dedicated monitoring account is three settings on each target (or one Group Policy):


  • DCOM: add the account to the Distributed COM Users group, which grants remote launch and activation.
  • Performance counters: add it to Performance Monitor Users so the Win32_PerfFormattedData classes answer.
  • Namespace security: in wmimgmt.msc, on the root\cimv2 namespace (and any application namespace you need, such as root\virtualization\v2 for Hyper-V), grant Enable Account and Remote Enable, applied to this namespace and subnamespaces.

Some classes still refuse non-administrators (the event log subscription classes among them), so decide early whether the saved privilege is worth the exceptions. Whatever account you use, store its password in the monitoring server encrypted and never in a script.


Testing WMI before you blame the monitor


A WMI query test from the monitoring server, as the monitoring account, settles most arguments. From PowerShell: Get-CimInstance Win32_OperatingSystem -ComputerName TARGET -Credential (Get-Credential) uses WinRM; Get-WmiObject Win32_OperatingSystem -ComputerName TARGET -Credential (Get-Credential) uses DCOM, which is what most monitors use, so it is the better test of the firewall path. The graphical wbemtest.exe ships with every Windows and lets you connect to \\TARGET\root\cimv2 and run a query by hand. A WMI tester built into the monitoring tool, which names the credential it used, saves the round trip.


WMI namespaces, classes, WMI Control, and the WMI explorer download question


WMI is organised into namespaces (root\cimv2 holds the operating system; others hold Hyper-V, DNS, Windows Defender and whatever applications registered a provider), classes within them, and properties on each class. There are thousands, and nobody memorises them. A WMI explorer, whether a standalone download or one built into the monitoring console, lets you browse a live machine namespace by namespace, see sample values, and pick a numeric property to graph. The practical rule: if a vendor's application exposes a WMI class, you can monitor it without an agent and without a script, which is the whole point of the technology.


WMI filters in Group Policy, and why they are not monitoring


You will meet "WMI filter" in a different context: Group Policy. A WMI filter in a GPO is a query that decides whether the policy applies to a machine ("only laptops", "only Windows Server 2022"), evaluated by the client against its own WMI data. It uses the same classes and the same query language, which is why the words collide, but WMI filtering in GPO has nothing to do with monitoring and does not need any ports opened. If a search brought you here for Group Policy, the thing to know is that a slow or broken WMI repository makes policy processing slow or wrong, and the repair section below applies.


WMI health: repository consistency, corruption and repair


The WMI repository is a database under %windir%\System32\wbem\Repository. It can become inconsistent, usually after a crash or a disk error, and the symptoms are queries that return nothing, "Invalid class" errors, or a Winmgmt service that will not start. The sequence, least to most drastic: winmgmt /verifyrepository reports whether it is consistent; winmgmt /salvagerepository rebuilds it from the existing files, keeping what it can; winmgmt /resetrepository starts over with the defaults, after which applications that registered providers may need to re-register them. Stop the service first, and expect a reboot at the end. A WMI health check on every monitored server, as a sensor, catches the inconsistent repository before the morning it matters.


WMI tester, WMI query test, WMI health check and WMI calls from a client

A WMI tester is any tool that makes a WMI call from a client machine and reports the result: wbemtest, PowerShell, or the test built into the monitoring console. A WMI query test proves the class answers; a WMI health check proves the repository is consistent and the service is running. Run both from the monitoring server as the monitoring account, because that is the combination that will fail at 3 a.m. if anything does.


WMI failed, WMI corrupted, WMI issues: when WinRM is the way out

If a host's WMI repository is corrupted and the salvage fails, or a firewall between you and it will never pass DCOM, configure server monitoring using WinRM instead: PowerShell remoting on TCP 5985 or 5986 reaches the same classes over one port. Microsoft treats DCOM-based WMI as legacy, and WinRM is where new deployments should start.


WMI troubleshooting: symptom to cause


SymptomMost likely causeCheck
"The RPC server is unavailable" (0x800706BA)Firewall: 135 open but the dynamic range closed, or the target is offEnable the WMI rule group; Test-NetConnection TARGET -Port 135
"Access is denied" (0x80070005)Account lacks DCOM or namespace rights, or UAC remote restrictions on a local accountTry a domain account; check Distributed COM Users and root\cimv2 security
"Invalid class" / empty resultsRepository inconsistent, or the provider for that class is not installedwinmgmt /verifyrepository
Performance counters return nothingAccount not in Performance Monitor Users, or the counters are corruptlodctr /r rebuilds the counters
Slow queries, timeouts, high CPU in WmiPrvSE.exeA provider misbehaving, or a huge event-log queryNarrow the query; check which provider the process hosts
Works for Administrators, fails for the monitoring accountNamespace rights not applied to subnamespacesRe-apply Enable Account and Remote Enable with "this namespace and subnamespaces"

Where to go next


With WMI reachable, the Windows network monitoring series covers what to actually watch on a Windows server and how to turn event logs into alerts without drowning in them. The custom checks and sensors series covers the counters nobody pre-packaged. And the product side, agentless Windows monitoring with a WMI explorer and a WMI test that names the credential it used, is on the Windows server monitoring page.


Put this into practice with SysPeep Monitor

SysPeep monitors Windows servers over WMI with nothing installed on them, runs all of a server's WMI queries in flight at once so one slow host never delays the rest, names the credential every test used, and turns any numeric WMI property into a graphed, thresholded sensor through its WMI explorer. Up to 5 devices are free at full depth.

Download Free TrialLearn About SysPeep