WMI GPO Filters for Operating System Types

As a standard practice in the environment I support we use WMI filtering on GPOs to ensure a GPO only gets applied to the right operating system type. This can prevent accidents such as applying a client GPO to a server, or a GPO for Server 2003 to a Server 2008 R2 system.

Creating WMI filters can be a pain, so here are the WMI queries that I use which cover a variety of operating systems.

Windows XP
select * from Win32_OperatingSystem WHERE Version LIKE “5.1%”

Windows 7
select * from Win32_OperatingSystem WHERE Version LIKE “6.1%” and ProductType = “1”

Windows Server 2003/R2
select * from Win32_OperatingSystem WHERE Version LIKE “5.2%”

Windows Server 2008
select * from Win32_OperatingSystem WHERE Version LIKE “6.0%” AND ( ProductType = “2” or ProductType = “3” )

Windows Server 2008 R2
select * from Win32_OperatingSystem WHERE Version LIKE “6.1%” AND ( ProductType = “2” or ProductType = “3” )

If you are wondering what the product types are, they are defined by Microsoft and distinguish between a client OS (1), domain controller (2) or member server (3). So you could easily create a filter to only apply to Windows Server 2008 R2 domain controllers, if you wished. Alternatively for 2008/R2 you could use AND ProductType “1” if you want something a bit shorter that covers both server product types.

To use these queries, open the GPMC. Expand down until you find the WMI Filters node. Right click on it and select New WMI Filter. Click Add, then paste the query of your choice into the query box. Give the filter a name, then you can apply it to any GPO in your forest.

WMI queries need not be limited to just querying operating system type. You could for instance apply a GPO only to systems with 8GB of RAM, a certain graphics card, hard drive size, or thousands of other parameters. A nice free tool I found for exploring WMI is WMI Explorer. It also lets you run queries, so you can validate that your query is working properly.

Print Friendly, PDF & Email

Related Posts

Subscribe
Notify of
1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Anonymous
March 13, 2012 12:18 am

Thank you, thats great!