// Enable WMI ObjectQuery query = new ObjectQuery("SELECT * FROM Win32_Service WHERE Name='winmgmt'"); ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query); ManagementObjectCollection results = searcher.Get();
Windows Server blocks remote WMI connections by default. You must enable the predefined WMI firewall rules. Run the following command in an elevated PowerShell session:
Before modifying network or firewall settings, ensure the underlying system service is functional. Press Win + R , type services.msc , and press . Locate Windows Management Instrumentation . Verify the Status shows Running .
The following API endpoints can be used to enable WMI on a Windows Server: