Group Policy Software Deployment: Targeting the right computers with WMI filters

By | September 6, 2011

WMI Filtering

With this method, you can filter the computers which are affected by your policy, based on common properties of the Operating System. For example, some packages might distinguish between 32-bit and 64-bit, some packages might only work on Vista or later, whereas other packages apply only to servers. With WMI, you can target the right computers without having to mess with group memberships (though you will probably still need to do that). For example:
32-bit vs. 64-bit computers
only workstations
only computers running a certain OS
only computers with a certain amount of RAM
only computers of a certain brand

With WMI filtering, you just create the software group policy, for example:

7-Zip 32-bit
7-Zip 64-bit

and then apply the respective WMI filter to them. But lets cut to the chase, here are a few WMI queries that you can cut & paste:

Operating System 32-bit
Select * from Win32_Processor where AddressWidth = ’32’
Operating System 64-bit
Select * from Win32_Processor where AddressWidth = ’64’

Workstation
Select * from WIN32_OperatingSystem where ProductType=1
Domain Controller
Select * from WIN32_OperatingSystem where ProductType=2
Server
Select * from WIN32_OperatingSystem where ProductType=3

Some filters require multiple WMI queries, which are just chained together.

Workstation 32-bit
Select * from WIN32_OperatingSystem where ProductType=1
Select * from Win32_Processor where AddressWidth = ’32’
Workstation 64-bit
Select * from WIN32_OperatingSystem where ProductType=1
Select * from Win32_Processor where AddressWidth = ’64’

Windows XP
Select * from WIN32_OperatingSystem where Version like ‘5.1.%’ and ProductType=1
Windows Vista
Select * from WIN32_OperatingSystem where Version like ‘6.0.%’ and ProductType=1
Windows 7
Select * from WIN32_OperatingSystem where Version like ‘6.1.%’ and ProductType=1

Windows 2003
Select * from WIN32_OperatingSystem where Version like ‘5.2.%’ and ProductType>1
Windows 2008
Select * from WIN32_OperatingSystem where Version like ‘6.0.%’ and ProductType>1
Windows 2008 R2
Select * from WIN32_OperatingSystem where Version like ‘6.1.%’ and ProductType>1

WIN32_OperatingSystem of course includes more information that can be useful for WMI queries, such as a descriptive name of the installed OS (“Name”) as well as the service pack installed (“ServicePackMajorVersion”).

Manufacturer (e.g. DELL)
Select * from WIN32_ComputerSystem where Manufacturer = ‘DELL’

Installed Memory (e.g. more than 1Gb)
Select * from WIN32_ComputerSystem where TotalPhysicalMemory >= 1073741824