locked
WMI Filters RRS feed

  • Question

  • i'm in a situation where I need to create a WMI filter to apply to group polices so those policies only take affect on Windows 7, Server 2008r2 and server 2012 r2 and do not take affect on Windows 8.1 machines...

    how would I do this?

    Thursday, March 19, 2015 1:28 PM

Answers

  • > i'm in a situation where I need to create a WMI filter to apply to group
    > polices so those policies only take affect on Windows 7, Server 2008r2
    > and server 2012 r2 and do not take affect on Windows 8.1 machines...
     
    select buildnumber from win32_operatingsystem where not ( buildnumber
    like "9%" and producttype = "1" )
     

    Greetings/Grüße, Martin

    Mal ein gutes Buch über GPOs lesen?
    Good or bad GPOs? - my blog…
    And if IT bothers me - coke bottle design refreshment (-:
    • Proposed as answer by Patris_70 Friday, March 20, 2015 9:18 AM
    • Marked as answer by Frank Shen5 Friday, March 27, 2015 8:29 AM
    Thursday, March 19, 2015 1:48 PM
  • Hello,

    Here are examples for Windows 8.1:

    Windows 8.1
    select * from Win32_OperatingSystem WHERE Version like “6.3%” AND ProductType=”1″
    Windows 8.1 (x86)
    select * from Win32_OperatingSystem WHERE Version like “6.3%” AND ProductType=”1″ AND NOT OSArchitecture = “x64″
    Windows 8.1 (x64)
    select * from Win32_OperatingSystem WHERE Version like “6.3%” AND ProductType=”1″ AND OSArchitecture = “x64″

    Windows 7, 8 and 8.1 example:

    select * from Win32_OperatingSystem WHERE (Version like “6.1%” or Version like “6.2%” or Version like “6.3%”) AND ProductType=”1″ 

    Regards


    • Edited by Patris_70 Friday, March 20, 2015 9:32 AM Windows 7, 8 and 8.1 example
    • Marked as answer by Frank Shen5 Friday, March 27, 2015 8:29 AM
    Friday, March 20, 2015 9:19 AM
  • > select * from Win32_OperatingSystem where Version like "6.1%"or Version
    > like "6.3%" and ProductType="3"
     
    You are aware that AND takes precedence before OR? So your query with
    parenthesis looks like that:
     
    select * from Win32_OperatingSystem where Version like "6.1%" or (
    Version like "6.3%" and ProductType="3" )
     
    I believe you want it to work more like that one:
     
    select * from Win32_OperatingSystem where ( Version like "6.1%" or
    Version like "6.3%" ) and ProductType="3"
     
    :)
     

    Greetings/Grüße, Martin

    Mal ein gutes Buch über GPOs lesen?
    Good or bad GPOs? - my blog…
    And if IT bothers me - coke bottle design refreshment (-:
    • Marked as answer by Frank Shen5 Friday, March 27, 2015 8:29 AM
    Friday, March 20, 2015 12:56 PM

All replies

  • > i'm in a situation where I need to create a WMI filter to apply to group
    > polices so those policies only take affect on Windows 7, Server 2008r2
    > and server 2012 r2 and do not take affect on Windows 8.1 machines...
     
    select buildnumber from win32_operatingsystem where not ( buildnumber
    like "9%" and producttype = "1" )
     

    Greetings/Grüße, Martin

    Mal ein gutes Buch über GPOs lesen?
    Good or bad GPOs? - my blog…
    And if IT bothers me - coke bottle design refreshment (-:
    • Proposed as answer by Patris_70 Friday, March 20, 2015 9:18 AM
    • Marked as answer by Frank Shen5 Friday, March 27, 2015 8:29 AM
    Thursday, March 19, 2015 1:48 PM
  • thanks for the reply. I'm currently testing the following:

    select * from Win32_OperatingSystem where Version like "6.1%"or Version like "6.3%" and ProductType="3"

    will give yours a try too, if mine doesn't work

    Friday, March 20, 2015 8:47 AM
  • Hello,

    Here are examples for Windows 8.1:

    Windows 8.1
    select * from Win32_OperatingSystem WHERE Version like “6.3%” AND ProductType=”1″
    Windows 8.1 (x86)
    select * from Win32_OperatingSystem WHERE Version like “6.3%” AND ProductType=”1″ AND NOT OSArchitecture = “x64″
    Windows 8.1 (x64)
    select * from Win32_OperatingSystem WHERE Version like “6.3%” AND ProductType=”1″ AND OSArchitecture = “x64″

    Windows 7, 8 and 8.1 example:

    select * from Win32_OperatingSystem WHERE (Version like “6.1%” or Version like “6.2%” or Version like “6.3%”) AND ProductType=”1″ 

    Regards


    • Edited by Patris_70 Friday, March 20, 2015 9:32 AM Windows 7, 8 and 8.1 example
    • Marked as answer by Frank Shen5 Friday, March 27, 2015 8:29 AM
    Friday, March 20, 2015 9:19 AM
  • > select * from Win32_OperatingSystem where Version like "6.1%"or Version
    > like "6.3%" and ProductType="3"
     
    You are aware that AND takes precedence before OR? So your query with
    parenthesis looks like that:
     
    select * from Win32_OperatingSystem where Version like "6.1%" or (
    Version like "6.3%" and ProductType="3" )
     
    I believe you want it to work more like that one:
     
    select * from Win32_OperatingSystem where ( Version like "6.1%" or
    Version like "6.3%" ) and ProductType="3"
     
    :)
     

    Greetings/Grüße, Martin

    Mal ein gutes Buch über GPOs lesen?
    Good or bad GPOs? - my blog…
    And if IT bothers me - coke bottle design refreshment (-:
    • Marked as answer by Frank Shen5 Friday, March 27, 2015 8:29 AM
    Friday, March 20, 2015 12:56 PM