What a week it's been, finally got caught up to this today and the first query 
you have is working great.  I'm pretty sure you're correct about not being able 
to use two where operators.

In case anyone is wondering, we had a situation where someone (one of our tech 
people thankfully) suddenly got 1703 from Microsoft Update even though we are 
set up properly for 1607 to point internally w/out dual scan.  Turns out that 
at one point the system was 1511 and had registry values added to properly set 
up the upgrade deferral, but those were not removed after it had been upgraded 
to 1607 (upgraded via SCCM).  So, I'm trying to add a policy that will remove 
the list of 8 reg values found in the January Microsoft 
blog<https://blogs.technet.microsoft.com/windowsserver/2017/01/09/why-wsus-and-sccm-managed-clients-are-reaching-out-to-microsoft-online/>
 post if it finds them on any Win10 machines that are not 1511.  I wanted to 
use AD wmi vs GPP targeting if possible so as to have to modify it less if the 
rules change again after 1703.

Thanks a bunch,
Bonnie

From: [email protected] [mailto:[email protected]] On 
Behalf Of Joseph L. Casale
Sent: Friday, June 2, 2017 2:38 PM
To: '[email protected]' <[email protected]>
Subject: [NTSysADM] RE: WMI query for AD

I tried looking for some info on how WMI plans and optimizes queries suspecting 
it was something like how SQL engines did but at least a quick search failed to 
find any info.

Regardless, I would write the queries like this:

select * from Win32_OperatingSystem where ProductType="1" AND Version like 
"10.0%" AND Version != "10.0.10586"

select * from Win32_OperatingSystem where ProductType="1" AND Version like 
"10.0%"
select * from Win32_OperatingSystem where Version != "10.0.10586"

Also, do you need all the fields returned? I didn't bench these but if they do 
behave like I would loosely imagine, ordering the constraints would reduce the 
result sets pushed into each consecutive predicate.

hth,
jlc

From: [email protected]<mailto:[email protected]> 
[mailto:[email protected]] On Behalf Of Miller Bonnie L.
Sent: Friday, June 2, 2017 3:05 PM
To: [email protected]<mailto:[email protected]>
Subject: [NTSysADM] WMI query for AD

Trying to craft a wmi filter for differences in update policies and preferences 
in AD.  I want it to select all versions of Win10 EXCEPT for 1511.  I have 
queries that work for 1511, 1607, and 1703, as well as all of Win10 and earlier 
OSes.

So, I'm trying to put those together and am having trouble when saving, it says 
I have a syntax error.  Is it not possible to query the same value twice at 
once?

               select * from Win32_OperatingSystem where (Version like "10.0%") 
AND (ProductType="1") AND where NOT (Version = "10.0.10586")

Or, is there some other syntax error I'm not catching, such as with the way I 
have the NOT statement.  I don't want it to run on our Win7 or 8.1 machines, 
and was hoping not to have to add each new version of Win10 going forward by 
doing this as an exclude.  I also noticed that the editor allows for multiple 
queries in one filter, so I'm not sure if they should rather be stacked like 
this:

               select * from Win32_OperatingSystem where (Version like "10.0%") 
AND (ProductType="1")

and then a second one for

               select * from Win32_OperatingSystem where NOT (Version = 
"10.0.10586")

Another option may be using GPP targeting if this doesn't work since most of 
what I want can be accomplished via registry changes.  I'm heading out but will 
pick this back up on Monday, so any suggestions are appreciated.

Thanks,
Bonnie

Reply via email to