Jump to content

WMI Filters for Windows 7, XP & Server 2008 R2 Terminal Server


Recommended Posts

Posted (edited)

 

They already are in there own OU. Anyway its a user policy so doing that wouldnt apply

Ok, sorry then, that's no help.

 

The WMI query is correct. The only thing I can think is that wmi doesnt correctly report the computer name at the point during startup where the filter is checked.

 

Maybe try filtering on DNSHostName instead?

 

 

Working now, just started to work for some reason

 

SELECT * FROM Win32_OperatingSystem WHERE (NOT CSName LIKE "LAP%") AND (Version LIKE "6.1%" AND ProductType = "1")

 

Will this code apply a policy to computers that:

Are not begging with LAP

But is a Windows 7 machine?

 

Thanks

Edited by FN-GM
Posted

Hi,

 

Im not in work so cant use the WMI Filter Validator. I just put this together, would this do the same as post 26 and only apply to 32 bit machines?

 

SELECT * FROM Win32_OperatingSystem WHERE (NOT CSName LIKE "LAP%") AND (Version LIKE "6.1%" AND ProductType = "1") AND (OSArchitecture='32-bit')

 

Would this apply to machines begging with LAP that are 32bit machines?

 

SELECT * FROM Win32_ComputerSystem WHERE (Name LIKE 'LAP%') AND (OSArchitecture='32-bit')

 

Sorry to pester just want to get this bang on :)

Posted

The first one looks fine, although you don't really need all of those brackets...

 

SELECT * FROM Win32_OperatingSystem WHERE (NOT CSName LIKE "LAP%") AND (Version LIKE "6.1%" AND ProductType = "1" AND OSArchitecture='32-bit')

[b]or[/b]

SELECT * FROM Win32_OperatingSystem WHERE NOT CSName LIKE "LAP%" AND Version LIKE "6.1%" AND ProductType = "1" AND OSArchitecture='32-bit'

 

The second filter won't work however because the Win32_ComputerSystem class doesn't have a property called OSArchitecture. Use this instead...

 

SELECT * FROM Win32_OperatingSystem WHERE CSName LIKE 'LAP%' AND OSArchitecture='32-bit'

  • Thanks 1
  • 3 months later...
Posted
Run this on one "wmic OS Get Caption" assuming it has that exe and then filter by what it says. it should give you the OS caption which it probably different and so filterable for.
  • 2 months later...
Posted

Sorry for the long reply. Only just got time to carry on with the project.

 

Once i have run that what would i do with the information displayed please?

Posted

A few examples...

 

Windows 7 Ultimate

Select * FROM Win32_OperatingSystem WHERE (Caption = "[color="#FF0000"]Microsoft Windows 7 Ultimate[/color]")

 

Windows 7 (All Editions)

Select * FROM Win32_OperatingSystem WHERE (Caption LIKE "[color="#FF0000"]Microsoft Windows 7[/color]%")

  • Thanks 1
  • 1 month later...
Posted (edited)

@Arthur Sorry for the long reply

 

What do we need the brackets for? If i want to use the above caption to detect 7 and 32 bit would this do please?

 

SELECT * FROM WIN32_OperatingSystem WHERE (Caption LIKE "Microsoft Windows 7%") AND (OSArchitecture='32-bit')

 

Thanks

Edited by FN-GM
Posted (edited)
What do we need the brackets for?

I'm not sure why I did it, but the brackets aren't required in the example above. I think I woke up too early that day. :)

 

For future reference, if you have a WMI filter which contains several different Boolean operators (ANDs and ORs for example), make sure you read this article first.

 

If I want to use the above caption to detect 7 and 32 bit would this do please?

Your example is fine. Another alternative would be to check the OS version...

 

SELECT * FROM WIN32_OperatingSystem WHERE Version LIKE '6.1.%' AND OSArchitecture='32-bit'

 

I would also try to avoid using too many WMI filters if you can. Item-level targeting of GPPs will almost always be faster (if that is an option?)...

 

WMI filters take some percentage of performance away each and every time Group Policy processing is evaluated. That is, at every logon, at startup and every 90 minutes thereafter, you'll take a little performance hit because WMI filters are re-evaluated. So, be careful and don’t link a GPO to the domain level or every single Windows XP machine and later will work hard to evaluate that WMI query. (Source)

 

WMI Filters have been around since Windows XP/2003 and are a great way to filter your Group Policy Objects based on the hardware of the computer that the policy is applied. However performing a WMI queries can take a substantial amount of time and if you have multiple WMI filters applying to your computers you have a significant performance decrease. Once again you can get around having to resort to using WMI Filters as Group Policy Preference Item-Level Targeting also have a number of options you can target hardware. Unlike WMI the Preference targeting engine has the performance advantage of being written in native code so it is much faster at determining what setting to apply. (Source)
Edited by Arthur
  • Thanks 1
Posted
I would also try to avoid using too many WMI filters if you can. Item-level targeting of GPPs will almost always be faster (if that is an option?)...

 

For what I am using it won't help :-) Also I only have a few I am tweaking existing ones.

 

I also can't use the WMI thta you posted as it picks up Windows Thin PC as well so that's why I am making tweaks to the existing ones.

 

 

Thanks for your help :-)

  • 3 weeks later...
Posted

Hi @Arthur do you know a WMI to pickup a clientname on an RDP session please? The option i want to do cant be done via group policy preferences.

 

Thanks

  • 4 weeks later...
Posted

Apologies for raising a very old thread here, I really dont normally do this, but this has thrown up a possible answer to a fiddly problem were having at the moment and I want to know if what I propose is achievable :-

 

SELECT * FROM Win32_OperatingSystem WHERE Version = '6.1%' AND ProductType = '1' AND ( OSArchitecture="32-bit" OR OSArchitecture="64-bit" )

 

Basically, we are now looking at Windows 7 64 bit in the school that I work in and we are finding that our GPOs arent applying to the 64 bit clients, this is because of the existing 32 bit only filtering in place, so I am obviously trying to create a WMI filter to allow us to include the 64 bit machines into the fray, would the WMI filter that I have put above work ? (I got it off an existing 64 bit WMI filter in our forest and wanted to know if what I have altered in here is going to get the results we want.

 

or can anyone help guide me in the right path if possible ?

 

Thanks,

 

Richard

Posted

select * from Win32_OperatingSystem where Version like "6.1%" and ProductType = "1"

 

That will pickup both 32 and 64

  • Thanks 1
  • 4 weeks later...
Posted

Slightly different take on the same theme:

 

I have the following working WMI filters:

 

Select * from Win32_OperatingSystem Where Version like "5.1%" and ProductType = "1"

Select * from Win32_OperatingSystem Where Version like "6.1%" and ProductType = "1"

 

So I can target XP and Win7 seperately.

 

I know want to add Win7 64bit in to the fray as a new WMI filter

 

Anything existing can be filetered as is I reckon, so I just need a new WMI filter so I can target specific policies to 64 bit windows 7.

 

Would this work for the new WMI filter?

Select * from Win32_OperatingSystem Where Version like "6.1%" and ProductType = "1" and AddressWidth="64"

 

I am also wondering if I should edit my existing WMI filter for Windows 7 so that it applies only to 32 bit.

 

Or would three WMI filters for Windows 7 give me most flexibility.

One for all flavours, one for 32 bit and one fore 64 bit

 

Does anyone else do it that way?

 

So I am guessing I would have:

 

Select * from Win32_OperatingSystem Where Version like "6.1%" and ProductType = "1" and AddressWidth="64"

Select * from Win32_OperatingSystem Where Version like "6.1%" and ProductType = "1" and AddressWidth="32"

SELECT * FROM Win32_OperatingSystem WHERE Version = '6.1%' AND ProductType = '1' AND ( OSArchitecture="32-bit" OR OSArchitecture="64-bit" )

 

Comments appreciated.

  • 2 months later...
Posted

I'm moving the way we deploy printers over to GPP and have got a problem where it causes an issue when logging onto Terminal Services. We don't need printers installing when using TS so I wanted to get a WMI filter to exclude the machines begining with TS. Can I do this by using something similar to below

 

 

SELECT * FROM Win32_OperatingSystem WHERE (NOT CSName LIKE "LAP%") AND (Version LIKE "6.1%" AND ProductType = "3")

 

 

Replacing LAP% for TS%

 

We still have some Windows XP clients so I thought it would be easier to apply the Group Policy only if the user wasn't logging onto a TS machine rather than applying it to every Windows Client we have.

 

Would this work?

Posted

I've tried this and it seems to work ok when I check it with the WMI Filter Validator

 

SELECT * FROM Win32_OperatingSystem WHERE (NOT CSName LIKE "TS%") AND (NOT ProductType="3")

 

Can anyone see any reason why I couldn't use this?

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...