combine dsquery and order the results

in sql we may do something like
SELECT NAME FROM TABLE
WHERE NAME LIKE '%POS%DEV%' OR NAME LIKE '%DEV%DEP%' OR NAME  LIKE '%PSR%DEV%' ORDER BY NAME DESC

can we combine the following three into one statement

dsquery * -filter "(&(objectcategory=computer)(name=*POS*DEV*))" -attr name
dsquery * -filter "(&(objectcategory=computer)(name=*DEV*DEP*))" -attr name
dsquery * -filter "(&(objectcategory=computer)(name=*PSR*DEV*))" -attr name
LVL 5
25112Asked:
Who is Participating?
 
Krzysztof PytkoSenior Active Directory EngineerCommented:
Hi,

have you tried this syntax? :)

dsquery * -filter "(&(objectcategory=computer)(|(name=*POS*DEV*)(name=*DEV*DEP*)(name=*PSR*DEV*)))" -attr name

Regards,
Krzysztof
0
 
25112Author Commented:
neat.. how about sorting them by alphabet?
0
 
Krzysztof PytkoSenior Active Directory EngineerCommented:
Unfortunately DS Tools doesn't allow for that :) They are old-fashioned tools. I would suggest to use for that Quest PowerShell module for AD. It's completely free and can be downloaded from
http://www.quest.com/powershell/activeroles-server.aspx

and use LDAP syntax

Get-QADComputer -LdapFilter "(&(objectCategory=computer)(|(name=*POS*DEV*)(name=*DEV*DEP*)(name=*PSR*DEV*)))" | select name | Sort-Object name

Krzysztof
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
25112Author Commented:
OK- thanks for explaining..

Get-QADComputer does not work for me, is it not part of win os like dsquery?
0
 
Krzysztof PytkoSenior Active Directory EngineerCommented:
Nope, as I wrote you need for that Quest PowerShell module for AD (separate PowerShell download). It's completely free but you need local administrative privileges to install it on your workstation

Krzysztof
0
 
25112Author Commented:
thank you Krzysztof for sharing your knowledge
0
 
Krzysztof PytkoSenior Active Directory EngineerCommented:
No problem, you're welcome :)

Krzysztof
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.