Wednesday, July 17, 2013

Handy WMI GPO filters

I thought I’d document a couple of WMI filters I’ve found handy when deploying software via Group Policy Objects (GPOs).  Windows Management Instrumentation (WMI) filters allow you to dynamically determine the scope of GPO based on attributes of the target computer.

When a GPO that is linked to a WMI filter is applied on the target computer, the filter is evaluated on the target computer. If the WMI filter evaluates to false, the GPO is not applied (except if the client computer is running Windows 2000, in which case the filter is ignored and the GPO is always applied). If the WMI filter evaluates to true, the GPO is applied.

Target Windows 7 32-bit machines

select * from Win32_OperatingSystem WHERE Version like "6.1%" AND ProductType="1" AND NOT OSArchitecture = "64-bit"

Target Windows 7 64-bit machines:

select * from Win32_OperatingSystem WHERE Version like "6.1%" AND ProductType="1" AND OSArchitecture = "64-bit"

Target any 32-bit OS:

SELECT AddressWidth FROM Win32_Processor WHERE AddressWidth ='32'

Target any 64-bit OS:

SELECT AddressWidth FROM Win32_Processor WHERE AddressWidth ='64'

Target Windows 7, Vista, Server 2008, Server 2008 R2 

select * from Win32_OperatingSystem where Version like "6.%" '

Target Windows 7, Server 2008 R2

select * from Win32_OperatingSystem where Version like "6.1%" '

Target Windows Server 2003

select * from Win32_OperatingSystem where Version like "5.2%" '

Target Server 2003, but not domain controllers

select * from Win32_OperatingSystem where Version like "5.2%" and ProductType="3" '

Target Server 2008 and 2008 R2, but not domain controllers

select * from Win32_OperatingSystem where Version like "6.%" and ProductType="3" '

Note:  Substitute ProductType="3" ' with ProductType="2" ' to just target domain controllers.