Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WMI System Enclosure Filter 1

Status
Not open for further replies.

gargon1

IS-IT--Management
Jan 24, 2003
15
0
0
VI
Hello,
I am trying to create a WMI Filter that determine what type enclosure a computer has so that I can determine if the system is a laptop. I have tried the query below but it fail even when I drop the objChassis. I used MS Scriptomatic tool to verify that I am using the correct WMI NameSpace, class and object. Can someone please tell me what I am doing wrong?

root\CIMv2 SELECT * FROM Win32_systemEnclosure WHERE objChassis.ChassisTypes = 10
 
I'm afraid you can't filter a WQL query on an array attribute.
a possible work around:
Code:
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_SystemEnclosure")
For Each objItem In colItems
  If InStr("," & Join(objItem.ChassisTypes, ",") & ",", ",10,") Then
    ' your stuff here
  End If
Next

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
PHV,
Thanks for responding. I tried running your query and it failed. I can troubleshoot and get it working but will it work as a group policy filter?
 
I tried running your query and it failed
Was the strComputer variable populated ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Chasis type can sometimes be flakey. I would suggest you query Win32_Battery since only a laptop will have a battery.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
PHV,
Thanks for pointing out the strComputer variable not being populated. The script worked after I populated it.
I am trying to use this as a WMI Filter in group policy. Can you please show me how to integrate the code I posted earlier into your script?
 
Markdmac,
Will I not run into the same issue that PHV pointed out? "I'm afraid you can't filter a WQL query on an array attribute.
 
the code I posted earlier
Which code ?
Furthermore I don't see how my workaround should be difficult to integrate anywhere ...
 
PHV,
Yes. The code you posted earlier. In the section of the code you posted, you commented 'your stuff here.


For Each objItem In colItems
If InStr("," & Join(objItem.ChassisTypes, ",") & ",", ",10,") Then
' your stuff here
End If
Next

How do I integrate, "SELECT * FROM Win32_systemEnclosure WHERE objChassis.ChassisTypes = 10"


 
i think you might be going in circles gargon1, from the posts it would appear you cant

where phv has put 'your stuff here, PHV is meaning that whatever action want to take based on the chassis type being 10 you should chuck the code 'your stuff here , there

it might be running an exe, updating AD etc etc
 
mrmovie,
That clears it up. Thank you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top