Jump to content

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


Recommended Posts

Posted

Hi,

 

I am after some WMI Filters. for the following

 

Windows XP Machines (32 Bit)

Windows 7 Machines (32 Bit maybe 64)

Windows Server 2008 R2 Terminal Server Session

 

I have found the following for Windows XP Machines

 

Root\CimV2; Select * from Win32_OperatingSystem where Caption = "Microsoft Windows XP Professional"

 

I have found this for Windows 7 Machines

 

select * from Win32_OperatingSystem WHERE Version like "6.1%" AND ProductType="1"

 

For Server 2008 R2 i have come up with nothing. As Server 2008 is windows 6.1 will it apply the above WMI? Maybe we could have something like this for Server 2008 R2 and 7? Will the below ones work?

 

Root\CimV2; Select * from Win32_OperatingSystem where Caption = "Microsoft Windows 7"

 

Root\CimV2; Select * from Win32_OperatingSystem where Caption = "Microsoft Windows Server 2008 R2"

 

 

Thanks

Posted

Ok so for windows XP i will have:

 

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

 

For Windows 7 I will have

 

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

 

For Server 2008 R2 i will have

 

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

 

Thanks allot

Posted
Beat me to it!

 

I deleted the last post as i cant read!

 

So do those filters sound ok to you?

 

I shall be doing some testing this weekend!

 

Thanks

Posted (edited)

I also assume you can apply these to user & computer policies?

 

Also i assume that the namespace is set to root\CIMv2

 

Thanks

Edited by FN-GM
Posted

Re: post #3, there are lots of different ways of doing the same thing... :)

 

[b]Windows XP[/b]
SELECT Version, ProductType FROM Win32_OperatingSystem WHERE Version = '5.1%' AND ProductType = '1'
SELECT Version, ProductType from Win32_OperatingSystem WHERE Version = '5.1.2600' AND ProductType = '1'
SELECT Version, ProductType from Win32_OperatingSystem WHERE Version LIKE '5.1.%' AND ProductType = '1'

 

[b]Windows 7[/b]
SELECT Version, ProductType FROM Win32_OperatingSystem WHERE Version = '6.1%' AND ProductType = '1'
SELECT Version, ProductType FROM Win32_OperatingSystem WHERE Version = '6.1.7600' AND ProductType = '1'
SELECT Version, ProductType FROM Win32_OperatingSystem WHERE Version LIKE '6.1.%' AND ProductType = '1'

 

[b]Windows Server 2008 R2[/b]
SELECT Version, ProductType FROM Win32_OperatingSystem WHERE Version = '6.1%' AND ProductType <> '1'
SELECT Version, ProductType FROM Win32_OperatingSystem WHERE Version = '6.1.7600' AND ( ProductType = '2' OR ProductType = '3' )
SELECT Version, ProductType FROM Win32_OperatingSystem WHERE Version LIKE '6.1.%' AND ProductType <> '1'

 

Some other filters you may find useful...

 

[b]32-bit OS[/b]
SELECT OSArchitecture FROM Win32_OperatingSystem WHERE OSArchitecture='32-bit'

 

[b]64-bit OS[/b]
SELECT OSArchitecture FROM Win32_OperatingSystem WHERE OSArchitecture='64-bit'

 

[b]NOT A Server OS[/b]
SELECT ProductType FROM Win32_OperatingSystem WHERE ProductType = '1'

 

[b]NOT a laptop (assumes every laptop uses SO-DIMM RAM)[/b]
SELECT FormFactor FROM Win32_PhysicalMemory WHERE FormFactor != 12

Posted

Does anyone have a WMI that will only apply a computer that begins with ZY4 please?

 

We have some computers called ZY4-01, ZY4-02 etc..

 

Thanks

Posted (edited)

SELECT * FROM Win32_ComputerSystem WHERE Name LIKE 'ZY4%'

[b]or[/b]

SELECT Name FROM Win32_ComputerSystem WHERE Name LIKE 'ZY4%'

 

In fact, you can query the computer name from literally any WMI class. e.g.

 

SELECT SystemName FROM Win32_ParallelPort WHERE SystemName LIKE 'ZY4%'

 

If you should ever need to query more than one group of computers, you can do it like this...

 

SELECT * FROM Win32_ComputerSystem WHERE (Name LIKE 'ZY4%' OR Name LIKE 'ZY5%')

Edited by Arthur
  • Thanks 1
Posted

Me again :)

 

I was wondering if you know of a WMI that will apply a user policy based on Client Name? I would like to apply a policy for users that use a thin client based on the thin client name. When you make a script in VBS instead of using computer name you use client name.

 

Do you have any ideas please?

 

Thanks

Posted

Sorry me again.

 

For re-directed start menus i will have to separate Windows 7 x86 & x64.

 

Would you use these WMI please?

 

select * from Win32_OperatingSystem WHERE Version like "6.1%" AND ProductType="1" AND WHERE OSArchitecture='32-bit'

 

select * from Win32_OperatingSystem WHERE Version like "6.1%" AND ProductType="1" AND WHERE OSArchitecture='64-bit'

 

Thanks

Posted

These should do it... :)

 

Windows 7 x86

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

 

Windows 7 x64

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

  • Thanks 1
  • 3 weeks later...
Posted (edited)

Hi me again :D

 

I want to make a WMI that will NOT apply to computers not begging with LAP.

 

Would this do the trick please?

 

SELECT * FROM Win32_ComputerSystem WHERE IS NOT Name LIKE 'LAP%'

 

Thanks very much :)

Edited by FN-GM
Posted

SELECT * FROM Win32_ComputerSystem WHERE NOT Name LIKE "LAP%"

 

or

 

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

 

The second WMI query will do what you originally wanted to do. ;)

  • Thanks 1
Posted

Ha thanks, :)

 

What i am doing it setup a redirected start menu, but i do not want it to apply when a user logs into a laptop.

 

Thanks

  • 1 month later...
Posted (edited)

Hi I am using this code to apply a group policy to laptops begging with LTOP.

 

SELECT * FROM Win32_ComputerSystem WHERE Name LIKE 'LTOP%'

 

The computer is called LTOP-001 but the policy does not apply with the WMI on. If i remove it the policy applies just fine when i enable it again it fails to work.

 

Any ideas please?

Edited by FN-GM
Posted

Aren't your laptops in a different OU? WMI filters are slow and shoudn't really be used instead of good AD organisation.

 

Make a Laptops OU, move them into it and apply the policy to that OU only.

Posted
Aren't your laptops in a different OU? WMI filters are slow and shoudn't really be used instead of good AD organisation.

 

Make a Laptops OU, move them into it and apply the policy to that OU only.

 

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

Posted
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?

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...