Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
1  
Do you standard computer models in your environment? If so, can you test on that? –  BigHomie Apr 30 at 13:02
1  
Is there a problem with using Item Level Targeting and letting Windows figure it out? –  BigHomie Apr 30 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 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 at 13:46

2 Answers 2

up vote 2 down vote accepted

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.

share|improve this answer
2  
Any computer is portable if you're man enough. –  Ryan Ries Apr 30 at 13:38
1  
@RyanRies it appears you are correct –  BigHomie Apr 30 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 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.

share|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 at 13:02
    

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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