Skip to content

TS - WMI Query help

Featured Replies

So, I have a few custom groups in my task sequence that install applications based upon some WMI queries using a naming convention. But I am having some issues trying to get it working exactly. Here is what I am trying to do.

I have two groups. Employee and Labs. The naming convention for employees is LIB-AU and for the Labs its LIB-AUXXXXX-XX where the X's represent numbers
image.png.92a370d17ad9f0b36b8a5f4cffd28402.png

I have this particular "If" statement. 

image.png.015b981b32de20f2986a62e77e4c00e6.png

Here is the query in question that I currently have for employee
SELECT * FROM Win32_ComputerSystem WHERE Not Name LIKE 'LIB-AU%-%'

Here is the query for the labs group. 
SELECT * FROM Win32_ComputerSystem WHERE Name LIKE 'LIB-AU%-%'

The behavior that occurs is that everything under the employees group installs to a system if it has the name "LIB-AUXXXXX-XX" - I don't want this to happen. I only want it to run the steps if it meets the 'LIB-AUXXXXX' naming, but otherwise skip it. The query for the "labs" group works fine.

Any suggestions?

TEST TEST TEST

I don't have a naming convention like this, but this "MIGHT" work--I suggest testing.  A lot.

Assumptions:
There are EXACTLY 5 numbers between the LIB-AU and the - for the Lab machines and then exactly 2 numbers after the -
There are EXACTLY 5 numbers for the LIB-AU ones where they don't have a - for employee machines

Labs:

Select * from win32_ComputerSystem Where Name like 'LIB-AU[0-9][0-9][0-9][0-9]-[0-9]-[0-9][0-9]'

Employees:
Select * from win32_ComputerSystem Where Name like 'LIB-AU[0-9][0-9][0-9][0-9][0-9]'

Why this might work....
the [0-9]; that's a WQL/SQL query trick. So you're saying... after the LIB-AU, that next character has to be a number between 0-9
Then the next character has to be 0-9
... up to 5 characters (for Employees)

For Lab, it has to be LIB-AU, then 5 numbers, then a -, then 2 numbers. 

 

  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.