To further build on Jason's comment, you can do some nifty stuff with
character ranges. For example, this is a [convoluted] way of matching 'Dell
Inc.'

 

Get-WmiObject -Query "Select * from Win32_ComputerSystem where Manufacturer
like '[a-d][e-g][l-o][l-o]%'"

 

http://msdn.microsoft.com/en-us/library/windows/desktop/aa392263(v=vs.85).as
px 

 

Cheers,

Trevor Sullivan

 <http://trevorsullivan.net/>     <http://twitter.com/pcgeek86>
<http://facebook.com/trevor.sullivan>
<https://plus.google.com/106658223083457664096> 

 

From: [email protected] [mailto:[email protected]]
On Behalf Of Jason Sandys
Sent: Friday, August 23, 2013 11:55 AM
To: [email protected]
Subject: RE: [mssms] Creating a membership rule query for a device
collection

 

Note that the underscore is also a wildcard in SQL/WQL as are what I call
character classes (similar to regular expressions).

 

% means 0 or more of any character

_ means 1 of any character

 

More info at http://www.w3schools.com/sql/sql_wildcards.asp

 

J

 

From: [email protected] <mailto:[email protected]>
[mailto:[email protected]] On Behalf Of Kevin Johnston
Sent: Friday, August 23, 2013 11:26 AM
To: '[email protected]'
Subject: RE: [mssms] Creating a membership rule query for a device
collection

 

Awesome thanks Ryan!!

 

From: [email protected] <mailto:[email protected]>
[mailto:[email protected]] On Behalf Of Ryan
Sent: Friday, August 23, 2013 12:16 PM
To: [email protected] <mailto:[email protected]> 
Subject: Re: [mssms] Creating a membership rule query for a device
collection

 

Wildcards are %.  If you use a wildcard, you need to use "like" instead of
"=".  Here is the query for all devices that start with L:

 

select
SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SY
STEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM
.Client from SMS_R_System where SMS_R_System.Name like "L%"

 

On Fri, Aug 23, 2013 at 11:10 AM, Kevin Johnston
<[email protected] <mailto:[email protected]> >
wrote:

In CM12 I created Laptop, workstation and server collections. I originally
had the membership setup as direct (during testing) and noticed that no new
machines are in these collections.

 

We mark all out laptops with the prefix of L and our workstations with W

 

Is there a way to make a query that says anything that starts with L put in
the laptop collection and anything that starts with W put in the workstation
collection?

 

I am not sure about wildcards.

 

But this is what I have:

 

select
SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SY
STEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM
.Client from SMS_R_System inner join SMS_G_System_COMPUTER_SYSTEM on
SMS_G_System_COMPUTER_SYSTEM.ResourceId = SMS_R_System.ResourceId where
SMS_G_System_COMPUTER_SYSTEM.Name = "L$"

 

Thanks,

 

Kevin Johnston

 

 

 

 

 

 



<<image001.gif>>

<<image002.gif>>

<<image003.gif>>

<<image004.gif>>

Reply via email to