WMI (Windows Management Instrumentation) provides a special interface in Windows used to manage the local or remote operating systems. WMI provides access to any operating system settings, hardware, system services, drivers, and applications.
The WMI service is critical to perform various management and administration tasks, and if it doesn’t work correctly, it can cause clients on the network to become unmanageable.
To quickly check the health of the WMI service on the local computer, you can use the Get-WmiObject PowerShell cmdlet:
Get-WmiObject -Query "Select * from win32_bios"
This simple WMI query should display information about your computer’s BIOS.
You can use Get-WmiObject to test WMI on a remote machine. Just add the -ComputerName parameter and specify the DNS name or IP address of the remote host:
Get-WmiObject -Query "Select * from win32_bios" -ComputerName wks221s
Note. You can request administrator credentials to connect to a remote computer:Get-WmiObject -Query "Select * from win32_bios" -ComputerName wks221s -Credential "MYDOMAIN\jbrion"
This command may return an error:
Get-WmiObject : The RPC server is unavailable.
Check if the Windows Management Instrumentation (Winmgmt) service is running on the remote computer:
Also check that the inbound WMI connections are allowed on the remote computer in Windows Defender Firewall. Enable the Windows Management Instrumentation (WMI-In) rule.
You can enable these firewall rules using PowerShell:
Enable-NetFirewallRule -Name "WMI-WINMGMT-In-TCP", "WMI-RPCSS-In-TCP"
Hint. In PowerShell Core 6.x+, WMI is not supported (because PowerShell Core is based on .Net Core). When running the Get-WmiObject command in pwsh.exe, the error “The term ‘Get-WmiObject’ is not recognized as a name of a cmdlet, function, script file, or executable program” will appear. Use CIM instead of WMI cmdlets.
The following command will query WMI data via CIM:
Get-CimInstance -Query "Select * from win32_bios"
You can use the built-in wbemtest GUI tool to connect to a local or remote WMI namespace. You can use wbemtest to test if WMI works properly:
- Run the command:
- Click the Connect button and enter the WMI Namespace you want to connect to. To connect to WMI on a remote computer, use the following connection string:
- Click the Query button and enter any WMI query. For example: SELECT * FROM Win32_OperatingSystem;
- If WMI works correctly, the utility will return a set of WMI objects. Double click on any entry. In this example, the WMI object contains information about the operating system of the computer.
On Windows, WMI object properties are stored in a special repository located in %SystemRoot%\System32\WBEM\Repository.
The winmgmt.exe command line tool is used to manage the WMI repository.
For example, run the following command in order to check the consistency of the WMI repository:
WMI repository is consistent
To check the WMI repository and fix all errors immediately:
To reset the WMI database to its default state, run: