Check WMI on SCCM-server

If you have problems with WMI on a SCCM server you have will have loads of strange things happening.

Wrote a small VBScript to check WMI… here it is:

Set oLocator = CreateObject("WbemScripting.SWbemLocator")

' --- Checking local WMI
WScript.Echo " Connect: root\CIMV2"
Set oWMIService = oLocator.ConnectServer(".", "root\CIMV2", "", "")

WScript.Echo "   Query: Select UUID from Win32_ComputerSystemProduct"
Set oWmiQuery = oWMIService.ExecQuery("Select UUID from Win32_ComputerSystemProduct")
For Each oUuid In oWmiQuery
        sUuid = oUuid.UUID
        WScript.Echo "Response: " & sUuid
        Exit For
Next
WScript.Echo ""

' --- Figure out site code
WScript.Echo " Connect: root\sms"
Set oWMIService = oLocator.ConnectServer(".", "root\sms", "", "")

WScript.Echo "   Query: SELECT SiteCode FROM SMS_ProviderLocation WHERE ProviderForLocalSite=true"
Set oWmiQuery = oWMIService.ExecQuery("SELECT SiteCode FROM SMS_ProviderLocation WHERE ProviderForLocalSite=true")
For each currentSite in oWmiQuery
        sSccmSiteCode = currentSite.SiteCode
        WScript.Echo "Response: " & sSccmSiteCode
        Exit For
Next
WScript.Echo ""

' --- Connect to site
WScript.Echo " Connect: root\sms\site_" & sSccmSiteCode
Set oWMIService = oLocator.ConnectServer(".", "root\sms\site_" & sSccmSiteCode, "", "")

WScript.Echo "   Query: Select Name, ResourceID FROM SMS_R_System WHERE SmbiosGuid = '" & sUuid & "'"
Set oWmiQuery = oWMIService.ExecQuery("Select ResourceID FROM SMS_R_System WHERE SmbiosGuid = '" & sUuid & "'")
For each myMachine in oWmiQuery
        WScript.Echo "Response: " & myMachine.ResourceID
        Exit For
Next

Or download here: wmiTester.vbs