9 Appendix D: Enumerating Class Schema
The following script shows how to enumerate the current class schemas on a Windows machine:
-
EnumerateSchema "root" sub EnumerateSchema(ns) if instr(ns,"LDAP") = 0 then wscript.echo "#pragma namespace(""\\\\.\\" & escapeit(ns) & """)" set wmi = getobject("winmgmts:\\.\" & ns) for each cls in wmi.subclassesof("") wscript.echo cls.getobjecttext_(0) next for each subns in wmi.instancesof("__namespace") EnumerateSchema ns & "\" & subns.name next end if end sub function escapeit(ns) escapeit = replace(ns, "\", "\\") end function
To use the script:
Save the script as "getmofs.vbs" on the target machine.
From a cmd.exe window, type "cscript getmofs.vbs > schema.mof". On Windows versions that support the Windows Integrity Mechanism, including the Windows Vista operating system and later versions, the CMD window is required to be "elevated", that is, run with administrative privileges.
The resulting output (in schema.mof) represents all of the class schemas on the particular system.