Test WMI Connection with PowerShell

Updated

Test WMI Connection with PowerShell

In this guide, you will learn how to use PowerShell to test WMI connections on a local and remote computer.

These commands are useful to quickly test WMI. By default, the windows firewall blocks WMI inbound connections, I’ll show you which rule to enable in the firewall.

Test WMI on Local Computer

This command will use WMI to query the local computer for the operating system.

Get-WmiObject -query "SELECT * FROM Win32_OperatingSystem"

You can see below the command returned the operating system info for my computer.

WMI query returning the operating system details for the local computer

Test WMI on Remote Computer

You can use the same command as above and just add the -ComputerName option.

In this example, I’m going to test the WMI connection to the remote computer PC1.

Get-WmiObject -query "SELECT * FROM Win32_OperatingSystem" -ComputerName PC1
Same WMI query run against a remote computer and returning results

Next, I’ll disable WMI in the firewall.

On PC1, I’m going to disable the rule “Windows Management Instrumentation (WMI-in) on the inbound rules.

Windows Firewall inbound rules with the WMI-In rule being disabled

Now when I run the WMI query to the remote computer the connection will fail because the firewall is blocking it.

WMI query failing against the remote computer with the firewall rule disabled

This firewall rule is disabled by default. If you need to run WMI queries on remote computers you need to enable the “Windows Management Instrumentation (WMI-in)” rule.

Windows Firewall inbound rules with the WMI-In rule enabled