We help IT Professionals succeed at work.

WMI Filter, is my syntax wrong? What am I missing? grr.

craylord
craylord asked
on
773 Views
Last Modified: 2008-01-09
I've setup a GPO to install an application (WU Client) and I only want it installed on the Windows XP workstations without SP1 or SP2. Here are the variations, in order that I tested.

SELECT * from Win32OperatingSystem WHERE BuildNumber=2600 and ServicePackMajorVersion=0
Followed by
SELECT * from Win32OperatingSystem WHERE BuildNumber=2600 and ServicePackMajorVersion<0
then by
SELECT * from Win32OperatingSystem WHERE BuildNumber=2600 and ServicePackMajorVersion="0"
then
SELECT * from Win32OperatingSystem WHERE BuildNumber=2600 and ServicePackMajorVersion IS NULL
by
SELECT * from Win32OperatingSystem WHERE Caption=Microsoft Windows XP Professional and ServicePackMajorVersion=0 (plus the variants above)

I also tried adding a second query instead of stringing two in the same one. I also used tried quotes, but logically, I shouldn't need them based on the example filters in the GPM console.

SELECT * from Win32OperatingSystem WHERE BuildNumber=2600
SELECT * from Win32OperatingSystem WHERE ServicePackMajorVersion=0

Still new to scripting with wmi. Thanks!
Comment
Watch Question

Hi,

I've never done any WMI in my life, however I have done a fair bit of PL/SQL and C etc.

In most lanuages x=y (assignment) is different to x==y (comparison), so it might be worth checking this out first.

Secondly I was looking at http://www.sqlservercentral.com/columnists/aloera/sqlserverscriptingandwmi.asp and found a similar line:

strWQL = "SELECT * FROM Win32_Process WHERE Name = '" & PROCESS_NAME & "'"

Sorry I can't help you more,

Thanks,

R
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
I think you pointed it out right graye. I may have been missing the _. But its curious as the filters included by MS don't have it. Combining the two into one didn't work, they had to be added as their own. So the end result was the single filter with two seperate queries. Each with the following line below. Thanks!

SELECT * from Win32_OperatingSystem WHERE BuildNumber=2600
SELECT * from Win32_OperatingSystem WHERE ServicePackMajorVersion<1

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.