Get list of computers in an active directory security group

I have a global security group in active directory that has computer members in it.  I want to export a list of them.  I used dsquery to do this from an OU but cannot find the right syntax to do it from a security group.  My current syntax is:

dsquery computer "?=security group,OU=Applications,ou=Groups,dc=ABC,dc=internal" -limit 0 -o rdn > c:\securitygroup_PCs.txt

What letters, instead of ?, go in front of =security group to indicate that it is a global security group and not an OU?

If it can't be done using dsquery, dsget or any other simple script will do.
BrianSDGAsked:
Who is Participating?
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.

N-WCommented:
Dsget should do the trick:
dsget group "CN=security group,OU=Applications,OU=Groups,DC=ABC,DC=internal" -members -expand > c:\securitygroup_PCs.txt

Open in new window


The "-expand" option will recurse any nested security groups and output the members from the nested security group too, omit it if that is not desirable.
0

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
BrianSDGAuthor Commented:
Thanks, it worked but I only want the computer names, not the whole CN.  How can I modify the command to just list the computer names?
0
Mohammed KhawajaManager - Infrastructure:  Information TechnologyCommented:
Try LDAP query such as below:

dsquery * -filter "(memberOf=cn=CompGroup,ou=West,dc=MyDomain,dc=local)" -attr sAMAccountName | find "$" /c
0
BrianSDGAuthor Commented:
Thanks!
0
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
Scripting Languages

From novice to tech pro — start learning today.