Need help building a query in Configuration Manager 2012 - We need to get all the Windows 2012/R2 2008/R2 that are not named like ABC

Hi,

We are building a query for a collection. The collection needs to have all the Windows 2008/R2 and Windows 2012/R2 that are but exclude the ones named like OLSREL, CIVOLSREL and OLSLAB

I have the following but I need to adjust the SMS_G_System_SYSTEM.Name like in order to remove all the servers named like ... from the results.

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 inner join SMS_G_System_SYSTEM on SMS_G_System_SYSTEM.ResourceID = SMS_R_System.ResourceId where SMS_R_System.OperatingSystemNameandVersion like "Microsoft Windows NT Server 6.2" and SMS_R_System.OperatingSystemNameandVersion like "Microsoft Windows NT Advanced Server 6.2" and SMS_R_System.OperatingSystemNameandVersion like "Microsoft Windows NT Server 6.3" and SMS_R_System.OperatingSystemNameandVersion like "Microsoft Windows NT Advanced Server 6.3" and SMS_R_System.OperatingSystemNameandVersion like "Microsoft Windows NT Advanced Server 6.1" and SMS_R_System.OperatingSystemNameandVersion like "Microsoft Windows NT Advanced Server 6.0" and SMS_G_System_SYSTEM.Name like "%OLSREL%" and SMS_G_System_SYSTEM.Name like "%CIVOLSREL%" and SMS_G_System_SYSTEM.Name like "%OLSLAB%"
llaravaAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

yo_beeDirector of Information TechnologyCommented:
1: Do you have any previous versions of Server OS in your environment?
2: Are there any other OLS Names of servers that you want to keep out of the query?

Since all the OS Version contain Server that you are looking to query you do not need all those additional Likes and if you only have server version that you are listing in your question you do  not even need to put the version number in the where clause.  You can just use '%server%'.

If not you can do something like this.

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 INNER JOIN
                      SMS_G_System_SYSTEM ON SMS_G_System_SYSTEM.ResourceID = SMS_R_System.ResourceId
WHERE     SMS_R_System.OperatingSystemNameandVersion LIKE '%Server 6.%') AND 
                      SMS_G_System_SYSTEM.Name LIKE '%OLS%'

Open in new window


If you need to do both OLSREL and OLSLAB then you might want to try this.

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 INNER JOIN
                      SMS_G_System_SYSTEM ON SMS_G_System_SYSTEM.ResourceID = SMS_R_System.ResourceId
WHERE     (SMS_R_System.OperatingSystemNameandVersion LIKE '%Server 6.%') AND 
                      (SMS_G_System_SYSTEM.Name LIKE '%OLSREL%' or SMS_G_System_SYSTEM.Name LIKE '%OLSLAB%')

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Applications

From novice to tech pro — start learning today.