Jump to content
Sign in to follow this  

Dump a WMI class

Recommended Posts


Is it possible to put this code to work, or am I so crazy?

On line 23, in "$ objItem." I plan on using a variable, or is there a better way to get the same result?

Best regards

I thank for your time.

$colItems = ""
$strComputer = @ComputerName
$strNamespace = "\root\CIMV2"
$strClass = "Win32_ComputerSystem"
$Output = ""
$Output &= "WMI for " & $strComputer & @CRLF
$Output &= "" & @CRLF
$objWMIServiceClass = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $strComputer & $strNamespace)
$objClass = $objWMIServiceClass.Get($strClass)
ConsoleWrite("$objClass.count: " & $objClass.Properties_().count & @CRLF)
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & $strNamespace)
$colItems = $objWMIService.ExecQuery("SELECT * FROM " & $strClass, "WQL");, 0x10 + 0x20)
ConsoleWrite("$colItems.count: " & $colItems.count & @CRLF)
For $objItem In $colItems
If IsObj($colItems) Then
  For $objProperty In $objClass.Properties_()
   $Output &= $objProperty.Name & ": " & $objItem.$objProperty.Name & @CRLF
   ;$Output &= $objProperty.Name & ": " & $objItem.AdminPasswordStatus  & @CRLF
  MsgBox(0, "WMI Output", "No WMI records found for class: " & $strClass)
$Output &= @crlf & " *** " & @CRLF
MsgBox(0, "", $Output)

Share this post

Link to post
Share on other sites

I'm at the same point, I can use a variable for the class (e.g Win32_Bios) but I can't get the $objitem. & $var to work either, I pull in my session criteria from a session.tmp which contains classname,itemname,1 the one denotes that it's a select audit item in my console app.

so if you make any headway on this I'd be interested as well


[font="'Arial Narrow';"]Current projects[/font]

[font="'Arial Narrow';"]are on my site [/font]Sellostring

Share this post

Link to post
Share on other sites


That's right, thank you.

I'm not so crazy after all, and you are an expert. ;)

With this optimal solution, I get a lot less lines of code. :graduated:


Nuno :)

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...