Group policy

WMI Filter – By OS and Servername

WMI Filter – By OS and Servername

I recently had to create a WMI filter on a GPO that would return true for all servers that are running windows 2008R2 with a certain name. I’ve done filters for one attribute before, but not two. Also the attributes I was looking for were in two different classes which sucked.

The OS can be returned from Win32_OperatingSystem and the name can be returned from Win32_ComputerSystem.I first tried stitching the two queries together, but this didn’t work. Then a colleague of mine who is a PS/WMI/SCOM/etc.. Guru suggested that I tried the built-in “__Server” property which worked nicely. Unfortunately (or fortunately) before this brain wave he got me to research “associators of” in WMI which is quite complicated, I couldn’t even attempt a copy and paste Frankenstein script as I didn’t understand about 90% of it.

Any-hoo the finished script is below. Please let me know if it helps

Select * from Win32_OperatingSystem Where Version like “6.1%” and __Server like “%NTS%"

I could probably of added the product type to make sure it only picks member servers, but with the __Server bit, it suits my purpose