NunoBorges Posted September 15, 2011 Share Posted September 15, 2011 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 More sharing options...
RichE Posted September 15, 2011 Share Posted September 15, 2011 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 More sharing options...
AdamUL Posted September 15, 2011 Share Posted September 15, 2011 Try this. $Output &= $objProperty.Name & ": " & Execute("$objItem." & $objProperty.Name) & @CRLF Adam Link to comment Share on other sites More sharing options...
NunoBorges Posted September 15, 2011 Author Share Posted September 15, 2011 Viva, 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. Sincerely Nuno Link to comment Share on other sites More sharing options...
AdamUL Posted September 15, 2011 Share Posted September 15, 2011 Thank you. I'm glad I could help. Adam Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now