Microsoft let us get soft for a while with WMI filtering. WIndows 2008, 2008 R2, 2012, and 2012 R2 were all WHERE Version like “6.%” in WMI filtering. Our WMI filters kept plodding along without anyone having to care. Then Windows 2016 hit and we had to start updating our filters for a new WHERE Version like “10.%” so we could target these new systems and so our filters would continue to work. Well now we have Windows Server 2019 which is also 10.0 version string so we can’t easily do like we did in the 2008-2012 era of 10.1, 10.2, etc. Now we have to care about WHERE Version like = “10.0.XYZ”…
In the past I had a generic WMI filter to get me all Windows 2016 and 2019 servers ignoring workstations.
SELECT Version FROM Win32_OperatingSystem WHERE Version LIKE “10.%” AND ProductType<>”1″
The problem is now I need to actually filter 2016 versus 2019 for targeting and that filter won’t do it. You can filter on specific Version to get a more granular filter. From this MS article we have the build numbers.
|Windows Server release||Version||OS Build|
|Windows Server, version 1903 (Semi-Annual Channel) (Datacenter Core, Standard Core)||1903||18362.30.190401-1528|
|Windows Server 2019 (Long-Term Servicing Channel) (Datacenter, Essentials, Standard)||1809||17763.107.1010129-1455|
|Windows Server, version 1809 (Semi-Annual Channel) (Datacenter Core, Standard Core)||1809||17763.107.1010129-1455|
|Windows Server, version 1803 (Semi-Annual Channel) (Datacenter, Standard)||1803||17134.1.180410-1804|
|Windows Server 2016 (Long-Term Servicing Channel)||1607||14393|
I’m only going to focus on LTS but if you needed to get super granular to the non-LTS releases the table can let you figure this out.
So now to target Windows Server 2016/2019 LTS you can alter the generic WMI to be more granular.
Windows Server 2016 LTS
SELECT Version FROM Win32_OperatingSystem WHERE Version = “10.0.14393” AND ProductType<>”1″
Windows Server 2019 LTS
SELECT Version FROM Win32_OperatingSystem WHERE Version = “10.0.17763” AND ProductType<>”1″
You’ll also be ready to WMI Filter on Windows Server 202X when it comes out with a new version string!
Note 1: If MS doesn’t update the table above you can get the Version of a new release using the following PowerShell.
Get-WmiObject -Class Win32_OperatingSystem
BuildNumber : 18362
Version : 10.0.18362
Note 2: Remember to copy these commands to a notepad doc and replace the ” because they’ll most likely be special characters and will break your filter…
5 thoughts on “Windows Server 2016 versus 2019 WMI Filtering”
“ProductType” should be “=3” for non dc and “=2” for dc servers i suppose (?)
Luckily those are still all the same so you can use those to pick between the two types.
yes but Windows server is not a product type 1. your wmi will work only because you wrote the build number with it, which is always differs from windows 10 build number. but when you want to ask for all win2019 servers you are going to use “10.%” and so you must specify the ProductType, 3 or 2 depending on the server.
In WMI <> is notation for not equal, so using not equal 1 returns 2 and 3 being all server types. You also can’t use just 10.% either because it also returns Windows Server 2016.
LikeLiked by 1 person
oh i see! Totally overlooked! Thank you for clarifying.