Link to home
Start Free TrialLog in
Avatar of Aerodrake
AerodrakeFlag for United States of America

asked on

How do I build an SCCM collection based on a letter in the computer name?

I am trying to create collections based on the machine names.

Lets say the the names are PROSERVD01, PROSERVP01, PROSERVS01

I would like the query to check the letter at the third position from the right (D,P,S) and display only machines that match a certain letter. Any help will be greatly appreciated.
Avatar of McNetic
McNetic
Flag of Germany image

Manually edit the sql query statement (it's labelled 'show sql" or "show query" or something) to look like this:

select * from SMS_R_System where LEFT(RIGHT(Name, 3), 1) = "D"
Avatar of Aerodrake

ASKER

Thanks for the reply.

I was working with the same idea.. but I'm getting syntax errors. I found this on a unrelated page, do you know if this is true for all WQL?

"Query Syntax is WQL not SQL - some minor syntactical differences.  In particular, advanced string manipulations are not supported in WQL (example: Right, Left, Substring, etc.)"
Source: http://securevantage.spaces.live.com/blog/cns!905E136EE69247B4!183.entry
I'm thought that query strings were sql strings directly issued to the sql server by sccm, but I'm not sure about that. I don't have a sccm server at hand to test it by mysqlf. I can't find any reference to sccm on the page linked by you, though.

However, if you now that the first part of the machine name is constant and equals to PROSERV, the following query should work:

select * from SMS_R_System where Name like "PROSERVS%"
select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System where SMS_R_System.NetbiosName like "COMP__NAME%"
Actually, a more decisive answer than what I put above.

select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System where SMS_R_System.NetbiosName like "PROSERVD%" or  SMS_R_System.NetbiosName like "PROSERVP%" or "PROSERVS%"
The machine names do not all start the same, hence the reason I'm looking for the 3rd letter from the end.
Are they consistent in the number of characters?  If so, then use the "_______D%" (7 x "_").  Otherwise, I would recommend using the first Experts comment and morph it with mine using the OR statements.
ASKER CERTIFIED SOLUTION
Avatar of Aerodrake
Aerodrake
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial