DiscoPosse – Using the chicken to measure IT
Technology, Cycling, Music and Madness


Technology

April 5, 2012

Group Policy WMI Filter – Laptop or Desktop Hardware

More articles by »
Written by: Eric
Tags: , , , , , , ,

In a previous article about WMI filters for Group Policy, I identified simple filters to make sure that GPOs will only apply to machines running a specific operating system such as Windows 7. This is helpful for separating workstations based on OS, but one of the most commonly asked for filter is whether the client is running on laptop or desktop hardware.

Many admins (myself included) use group membership to manage GPO distribution by adding computers or users to an Active Directory group and then adding that group using the Advanced options in the Delegation tag inside the Group Policy Management Console (gpmc.msc).

GPO Deny

In this example I’ve used a policy named GPO_LogonScript and then created a Active Directory group named DENY_GPO_LogonScript. This is handy for testing things like logon scripts so that you ensure that a group of users or computers block the processing of certain policies. You can achieve the same thing by using different OUs specifically for testing, but this allows you to not disrupt the other regular configurations and policies.

For us to use this method for laptops, we would have to explicitly add the laptop computer objects into an Active Directory group and apply the Deny attribute to the Apply Group Policy setting. While that will work, it requires manual intervention and as most of us know, manual changes lead to missed changes.

WMI Filtering for Hardware

This is where we can use the magic of WMI filters to automate the task of identifying a workstation type based on WMI properties. For my sample, I have a filter named Windows 7 Desktop Only where I am filtering based on the Caption property of the Win32_OperatingSystem class to define Windows 7, and also by the FormFactor property of the Win32_PhysicalMemory class.

 

The FormFactor property tells us what type of memory module is installed in the hardware device. For SODIMM memory which is used for laptops the FormFactor value will be 12. So to isolate the hardware type as desktop you simply use this query:

Select * from Win32_PhysicalMemory WHERE (FormFactor != 12)

Or for laptop detection, you want the query to be set to equal 12:

Select * from Win32_PhysicalMemory WHERE (FormFactor = 12)

Another method to detect hardware as laptop only is to look for the presence of a battery based on the BatteryStatus property of the Win32_Battery class.

By using the Win32_Battery class, we can search to see if there is a battery present. If the battery status is not equal to zero ( BatteryStatus <> 0 ) then you know that it is a laptop.

Select * from Win32_Battery WHERE (BatteryStatus <> 0)

On my laptop, I can run a GPRESULT /V and the filtered GPOs show up as Denied (WMI FIlter):

As always you will have to test these out and flavor taste according to your specific environment. You can also use these WMI filters inside SCCM, SMS, PowerShell and a variety of other management tools and scripts in order to report, manage and monitor on your environment.

Happy filtering!

 



About the Author

Eric





 
 

 
sccmLogo

Remove old Active Directory computer accounts from SCCM

A common issue in IT organizations is that the removal of computer objects is not done regularly. While I’ve presented scripts for removing old computer accounts from Active Directory, I’ve recently had to extend th...
by Eric
0

 
 
Console

Multi-Environment PowerShell console – AD, Exchange and PowerCLI in one happy place!

With the increase in the use of PowerShell as part of an administrator’s toolkit, it can be challening with multiple shells to administer different environments. I prefer using a single, multi-functional console, so wha...
by Eric
3

 
 
featured_powershell

PowerShell – Move Windows 7 Computers into OU structure by IP address (Active Directory)

Hi Folks! I’f you’ve come to this article because of a permalink then I’ve got some news for you! The article has been selected to be posted on the Microsoft Scripting Guys blog as a guest article (insert appl...
by Eric
0

 

 
featured_powershell

PowerShell – Get serial numbers for computers in Active Directory

There are a lot of posts about pulling data from a file to do actions against computers/users. While this is valuable, I prefer to do dynamic capturing of computer and user objects directly from my Active Directory. This is a s...
by Eric
0

 
 
featured_powershell

PowerShell – Active Directory – Email users with password expiry < 14 days

PowerShell – Active Directory – Email users with password expiry under 14 days This script is handy for users who are not typically on your network (remote access, email only etc…). Normally users are warned a...
by Eric
2

 




Join Zipcar and get $50 in free driving Join Zipcar and get $50 in free driving Join Zipcar and get $50 in free driving

3 Comments


  1. Great post, Eric.

    This WMI filter for GPO is quite the hot topic around AD administrators circles and considered the Holy Grail of filters. The memory formula ‘usually’ works, however, all modern Dell computers (laptops and desktops) report a memory form factor of 8, so it unfortunately doesn’t work form them.

    The Batter Status filters if you want to catch laptops, but unfortunately, it doesn’t help in identifying desktops (there’s no batter status field, so it doesn’t even return 0 or NULL).

    Cheers!
    Matt
    @mattvogt


  2. Thanks Matt!

    You are absolutely right about the limits of the 2 query types. It is a challenge to find the ideal because each can get different results. We could also blame Dell ;)

    I’ve got a hybrid of the two running. For Desktops I look for FormFactor and for laptops I look for battery. You would think that there would be a nice simple Laptop=1 field somewhere.

    Eric


  3. Oh, I do blame Dell, or at least their main board/memory manufacturer choices ;)

    Wouldn’t that be great? My great hope is that client side targeting (ala GPPs) will eventually come to GPOs.



Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>