I have a challenge where I want to use a GPO to set a Power Plan.
Working on constructing a WMI Filter (using WQL), I ran into a problem of determining a set of WQL statements that would always return true
for desktops/servers and false
for laptops/notebooks.
I began by testing the use of win32_systemenclosure
property ChassisTypes
, but quickly found that ChassisTypes
is an int array
, which can not be used in (standard) WQL [although it's available in the SCCM WQL extension set].
Next I found references to use win32_battery
and check the Status
property for a non-zero value; but I quickly realized that this will return a value on desktops and servers that have a UPS attached via USB.
Since none of the above will always (+/- tolerable N) return true
for desktops/servers, and false
for laptops/notebooks, I located the win32_portablebattery
class.
Excited, I began testing and quickly noticed that win32_portablebattery
returns nothing when executed against a desktop or server. By "nothing" I don't mean {empty string}/""
, I don't mean NULL
, and I don't mean false
, I mean literally nothing. I have even attempted to check __CLASS = ""
and __CLASS IS NULL
and both still return false
for desktops and servers.
Does anyone know any further WQL
-fu to try to get a true
results using win32_portablebattery
?
Not an exact answer to your question, but it might work for you.
I use the form factor of the memory to do determine whether or not something's a laptop. So our WMI filter, which returns
true
on laptops is:Select * from Win32_PhysicalMemory where FormFactor = 12
If you need it to return
false
,(FormFactor != 12)
, of course. If you punch that WMI query into Google, you get a fair number of results back which seem to indicate that it's a reliable test, but you'll probably want to do some testing yourself first. It works in my environment, without any incorect detections I'm aware of, so it might work for yours as well.There are two things you can do.
If you have standard computer models, you can filter based on the
Win32_ComputerSystem
model property.If you're using group policy preferences, you can use
Item Level Targeting
to filter out what users/computers the policy applies to based on a myriad of factors. One of these being Portable Computer Targeting. In a nutshell, Windows will determine if the machine is portable or not.I like #2 personally because if it's misapplied then you can always blame Microsoft and tell a user
MS thinks your computer is supposed to be portable.
I have a laptop in front of me that does not return an object when querying Win32_PortableBattery, but returns an object when querying Win32_Battery. Probably not a good option to use either of these classes.