Hello libanfahad-5883,
Thank you for posting here.
For Windows Server 2019 but not server 2022, please try the following WMI query:
select version from win32_operatingsystem where version like '10%' AND version >= '10.0.17763'
and
select version from win32_operatingsystem where version like '10%' AND version < '10.0.20348'
OR
select version from win32_operatingsystem where version like '10%' AND version >= '10.0.17763' and version < '10.0.20348'
For more information, please refer to links below.
Create WMI Filters for the GPO
https://learn.microsoft.com/en-us/windows/security/threat-protection/windows-firewall/create-wmi-filters-for-the-gpo
WMI Filter for 2019
https://social.technet.microsoft.com/Forums/en-US/9d0ea943-b0c8-4c16-9374-13d68359adf5/wmi-filter-for-2019?forum=winservergen
OS Version Queries for WMI Filters
http://www.nogeekleftbehind.com/2016/01/19/os-version-queries-for-wmi-filters/
Hope the information above is helpful. If anything is unclear, please feel free to let us know.
Best Regards,
Daisy Zhou
============================================
If the Answer is helpful, please click "Accept Answer" and upvote it.