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?

  • 1
    Do you standard computer models in your environment? If so, can you test on that? – MDMoore313 Apr 30 '14 at 13:02
  • 1
    Is there a problem with using Item Level Targeting and letting Windows figure it out? – MDMoore313 Apr 30 '14 at 13:04
  • Change that to an answer. That sounds like a great idea, not a direct answer; but I'll mark it anyway, because I fall into "camp 5". – mbrownnyc Apr 30 '14 at 13:13
  • Sorry for the confusion, I fit into "camp 6"; a righteous, consuming, chaotic rebel, who takes from the nothing and gives fake internet points to the poor. Upvotes all around. – mbrownnyc Apr 30 '14 at 13:46

There are two things you can do.

  1. If you have standard computer models, you can filter based on the Win32_ComputerSystem model property.

  2. 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.

|improve this answer|||||
  • 2
    Any computer is portable if you're man enough. – Ryan Ries Apr 30 '14 at 13:38
  • 1
    @RyanRies it appears you are correct – MDMoore313 Apr 30 '14 at 13:40
  • I am applying a power plan, and 34 registry keys (disabling hibernation, setting NICs to not power off to save energy), and had a lot of fun clicking between 400 and 1000 times setting this up [but, hey, it's only done once]. I used a Collection returning false, testing for all three docked conditions, OR select caption from win32_portablebattery where caption like "%ortable%" from Root\cimv2 returns a value for caption (property). – mbrownnyc Apr 30 '14 at 15:07

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.

|improve this answer|||||
  • Thanks. This is probably reasonable, except that in some years, we might be using some desktop model that supports SODIMM (like a HP 8300 ELITE USDT). This was referred to in the technet thread referenced earlier. I know without a doubt that win32_portablebattery will be 100% reliable; but if I can't locate any way to use it, then I'll use this. I guess I could just pull a report to see how viable it is. – mbrownnyc Apr 30 '14 at 13:02

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.

|improve this answer|||||
  • This isn't really an answer (unless you have a solution you can add by editing), but would be an appropriate comment to the original question. Anyway, I do appreciate the input, and will have to double check all new models! – mbrownnyc Oct 30 '14 at 23:45
  • It may also be worth noting that if one were to somehow design some sort of query which assumes that any system which returns no result is a laptop, they may be in for a surprise when they start having virtual machines running Windows become a part of their network. Windows in a VM seems to return unusual results for Win32_PhysicalMemory (which makes sense) for example. – RedScourge Nov 26 '14 at 2:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.