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.
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
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.
Now when I run the WMI query to the remote computer the connection will fail because the firewall is blocking it.
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.