Jump to content

Dump a WMI class


NunoBorges
 Share

Recommended Posts

Viva,

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
  Next
Else
  MsgBox(0, "WMI Output", "No WMI records found for class: " & $strClass)
EndIf
$Output &= @crlf & " *** " & @CRLF
Next
MsgBox(0, "", $Output)
Link to comment
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

RichE

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

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

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...