WMI Query not evaluated correctly

Hi All,

I am building 1 task sequence for all our different departments.
Therefore I created different "install application" steps with WMI query on the PC hostname to find the department like for example ICT:

select * from win32_computersystem where Name like "ICT%"

There are also other applications that need to be installed for every department except for ICT so I would like to create a WMI query like this:

select * from win32_computersystem where NOT Name like "ICT%"

This is not working as expected so I tried a different option.
"if NONE of the conditions is true:"
select * from win32_computersystem where Name like "ICT%"

The condition evaluates correctly for a new laptop deploying Windows 10 but not for an older PC deploying Windows 7.

Is it an issue with Windows 7 or with the PC?
If I open cmd during task sequence and I execute the query I do get a correct response but SCCM still evaluates not correct.

Any ideas?

Thanks!

August 25th, 2015 1:54pm

Look at this thread, it should solve your issue :

https://social.technet.microsoft.com/Forums/systemcenter/en-US/5d549159-554b-4e64-bba6-aefebe475494/osd-skip-a-task-sequence-step-by-query

Another thing you could do is create an empty "Department" variable to prompt the admin when the computer starts and base your query on this variable instead of the name.

I made a blog post on how to achieve that :

http://www.systemcenterdudes.com/collection-variables-task-sequence/

Free Windows Admin Tool Kit Click here and download it now
August 25th, 2015 3:29pm

Thanks for the reply Benoit.

I only don't see any difference between the suggestion in your first link and my query.

What is wrong with this one I am using?
select * from win32_computersystem where NOT Name like "ICT%"

This is a valid WMI query and I use it on my install application step so I assume if I test this on my pc named ICT-TEST it should skip the step because the condition is evaluated true?

The other suggestion is not an option since we want a zero touch installation

Regards

August 25th, 2015 3:47pm


Your above query evaluates as false (where not name like "ICT%" on a computer named ICT-test) so that's your problem if you have the task sequence step evaluated as true because it is not. The query returns zero results because the name is ICT-TEST and therefore returns zero results (condition = false).

You can use WBEMTEST to test your queries pretty easily. Also, change your condition to "if ALL of the conditions are FALSE".


Free Windows Admin Tool Kit Click here and download it now
August 25th, 2015 11:11pm

Sounds correct Narcoticoo,
but can you explain why this works on a new Windows 10 laptop as expected and not on an older Windows 7 PC?
WBEMTEST indeed returns nothing but no error so it is correct query.
I don't know how I can change the "if ALL of the conditions are TRUE" to FALSE?
For now I use this:

The step should be skipped for a computer named ICT-TEST.

I also have another step with all the ICT applications with these settings:

I guess this should evaluate to TRUE and execute the step for a pc ICT-TEST?
Why is the step skipped?

  • Edited by vivdb 1 hour 25 minutes ago
August 26th, 2015 2:24am

What does the Powershell command 
gwmi -class win32_computersystem 

return on both machines?

Free Windows Admin Tool Kit Click here and download it now
August 26th, 2015 2:31am

Torsten,

As requested:

On the PC with Windows 7 (which evaluates not correct):

On the new laptop with Windows 10 (which evaluates correct):

August 26th, 2015 2:47am


Your above query evaluates as false (where not name like "ICT%" on a computer named ICT-test) so that's your problem if you have the task sequence step evaluated as true because it is not. The query returns zero results because the name is ICT-TEST and therefore returns zero results (condition = false).

You can use WBEMTEST to test your queries pretty easily. Also, change your condition to "if ALL of the conditions are FALSE".


  • Edited by Narcoticoo Wednesday, August 26, 2015 3:19 AM
Free Windows Admin Tool Kit Click here and download it now
August 26th, 2015 3:09am

Update:

I deployed Windows 10 instead of Windows 7 on the older PC and now the conditions are also evaluated correct...
Since we deploy mostly Windows 7 I would love to see this work to...

August 26th, 2015 3:52am

Sounds correct Narcoticoo,
but can you explain why this works on a new Windows 10 laptop as expected and not on an older Windows 7 PC?
WBEMTEST indeed returns nothing but no error so it is correct query.
I don't know how I can change the "if ALL of the conditions are TRUE" to FALSE?
For now I use this:

The step should be skipped for a computer named ICT-TEST.

I also have another step with all the ICT applications with these settings:

I guess this should evaluate to TRUE and execute the step for a pc ICT-TEST?
Why is the step skipped?

  • Edited by vivdb Wednesday, August 26, 2015 6:26 AM
Free Windows Admin Tool Kit Click here and download it now
August 26th, 2015 6:21am

Update:

The querys are working as expected on all devices except 1 test machine.
When I deploy Windows 10 or Windows 7 English it is also working but when I deploy Windows 7 Dutch it doesn't work at all...

I compared the smsts log files on 2 devices:

Working device (ICT-XXXX-LPT):

Not working device (ICT-TEST-397):

Any ideas?

August 26th, 2015 7:51am

Just a note, always deploy English base OS and add language pack to that...Can you open cmd at that point and try webemtest?
Free Windows Admin Tool Kit Click here and download it now
August 26th, 2015 1:56pm

Wbemtest executes the query correct and gives the correct hostname.

After trying a lot of different scenarios every build was working except Windows 7 Dutch on this PC only.
I removed the PC from SCCM and imported it again, deployed the Windows 7 Dutch image again and now works without issues.

I think something got messed up in the database somehow...

Problem solved :-)

August 27th, 2015 3:13am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics