Photo by Nathan Dumlao / Unsplash
WMI Filter to identify 32 and 64 bits

WMI Filter to identify 32 and 64 bits

Published on 03 Aug 2020

Bastien Perez
Bastien Perez

Clap

A lot of bad WMI filter on the Internet

I create Group Policy Objects for years and I am often consulted to solve GPO issues. Lately I had to debug GPOs created by an IT admin. This GPO has applied randomly on the workstations.

All these GPO use the following WMI Filters to identify 32 and 64 bits computers (PLEASE, KEEP READING BUT NOT USE THESE WMI FILTER):

SELECT * FROM Win32_OperatingSystem WHERE OSArchitecture="32-bit" SELECT * FROM Win32_OperatingSystem WHERE OSArchitecture="64-bit"

At the first glance, everything seems to be OK. A brief Google search brings me a LOT of blog/documentations with this filer. Some people indicates to use SELECT * FROM Win32_OperatingSystem WHERE NOT OSArchitecture = "64-bit " for 32 bits (spoiler: don’t use it neither).

So, what is the problem? I ran a Get-WMIObject -Query ‘SELECT * FROM Win32_OperatingSystem WHERE OSArchitecture="64-bit" and I get… nothing… it’s odd because my computer is a 64bit CPU and OS.

After, I tried Get-WmiObject -Query 'SELECT OSArchitecture FROM Win32_OperatingSystem':

With this command, I got the culprit: on my system, installed in french language, the OS Architecture value is 64 bits and not 64-bits (note the dash).

The good WMI filters for 32 or 64 bits

If you work in multi-language environment (or even if any environment), only use following WMI Filters:

# 32bits
SELECT AddressWidth FROM Win32_Processor WHERE AddressWidth="32"

64 bits
SELECT AddressWidth FROM Win32_Processor WHERE AddressWidth="64"

Comments

banner-Bastien Perez
Bastien Perez

Freelance Microsoft 365 - Active Directory - Modern Workplace

France