Monday June 15, 2009 12:00

Listing All Win32 CIMv2 Providers

Posted by chrishota

When starting to troubleshoot a Windows Server problem, the best place to look is the Windows Management Instrumentation (WMI); this little enclave of information—on every Windows machine—acts like a datastore representing the configuration of every nook and cranny of a system. But knowing what to look for is half the battle.

Recently, I was faced with diagnosing slow replication times for Branch Office Distributed File System Replication under Windows Server 2003. I had no idea where to look, so I referenced the following script, pointed the two instances of strComputer to our DFS-enabled file server, and looked for DFS-specific properties and methods:

cscript "List Win32 Providers.vbs" | grep -i dfs

This gave me the performance counters I could use to monitor performance, as well as how to programmatically create DFS shares and namespaces.

strComputer = "."
Set objWMIService=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
 
For Each objclass in objWMIService.SubclassesOf()
    intCounter=0
    If Left(objClass.Path_.Class,5) = "Win32" Then
        For Each Qualifier in objClass.Qualifiers_
            If UCase(Trim(Qualifier.Name)) = "ASSOCIATION" Then
                intCounter = 1
            End If
        Next
        If x = 0 Then
            strComputer = "."
            Set objWMIService = GetObject _
                ("winmgmts:{impersonationLevel=impersonate}!\\" & _
                    strComputer & "\root\cimv2")
            Set strClass = objWMIService.Get(objClass.Path_.Class)
            Wscript.Echo "PROPERTIES:"
            For each strItem in strClass.properties_
                Wscript.Echo objClass.Path_.Class & vbTab & strItem.name 
            Next
            Wscript.Echo "METHODS:"
            For Each strItem in strClass.methods_
                Wscript.Echo objClass.Path_.Class & vbTab & strItem.name 
            Next
        End If
    End If
Next

1 Response to Listing All Win32 CIMv2 Providers

Avatar

Force Command-Line for VBScripts | Savory Ape

June 17th, 2009 at 12:06pm

[...] you have a script—like the previous CIM Repository Listing script—that outputs hundreds of rows of text via WScript.Echo. On the command line, this is fine; [...]