Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 4944
  • Last Modified:

help with dsquery and dsget

I need help with the dsguery and dsget command.
I have an OU = Distro
inside of the OU there there is a Group scope that is = Universal
The group type is =  Distribution
The group name is = ACL Team
This group has users object and contact object as the memebers of this distribution group.

I need information from this distribution group.
I need from the users in this group thier email address
I need from the contact object the email address

could you help me with this command and out put the result to a file.
I am missing the part how to get the information from the contacts in this distribution group

also let me know about the spaces in between the commands
dsquery group -name "ACL Team" | dsget group -members | dsget user -email -display > c:\Group\ACL.txt

Open in new window

  • 3
  • 2
1 Solution
ccdc12Author Commented:
when I run the command I get the error
dsget fail: CN= Name of Contact, OU=Glenwood,DC=com: The object clas of the target not match the one specified on the command line.
type line.
type dsget /? for help. Email

When the distribution group has a contact object in with the user object I  get this error.
If the distribution group only has user object I don't get an error

I think it is because I do not have the command to handle the contact object .

ccdc12Author Commented:
can a wild * be used?
Chris DentPowerShell DeveloperCommented:

I see your choices as this:

1. Use "DSQuery *" to return membership using an LDAP filter returning only specific object classes. e.g.

dsquery * -Filter "(&(objectClass=user)(objectCategory=person)(memberOf=CN=ACL Team,OU=somewhere,DC=yourdomain,DC=com))"

Then pipe that into "dsget user".

2. Upgrade to something more capable / more flexible.

If you go for upgrading I would suggest you get this:


Then this:


Both of those are free. Then all you need to do is run this in the shell that it installs:

Get-QADGroupMember "ACL Team" | Select-Object Name,Email

Simplify Active Directory Administration

Administration of Active Directory does not have to be hard.  Too often what should be a simple task is made more difficult than it needs to be.The solution?  Hyena from SystemTools Software.  With ease-of-use as well as powerful importing and bulk updating capabilities.

ccdc12Author Commented:
I installed the powershell but I could not get the command posted above.
instead of trying to get the powershell command to work...

I am in a time crunch....

could you please provide the command that will work the quickest and easyest..

I have several groups to get who is the memeber and the emails and the contact email in each group


Chris DentPowerShell DeveloperCommented:

PowerShell is quickest and easiest for me to explain :)

Either run the version of PowerShell from the Quest Software folder in the Start Menu, or run this first:

Get-PSSnapIn -Reg | Add-PSSnapin -ea 0

It's likely that you're running the version without the additional commands added (because I didn't say you needed to do otherwise). Once you have those loaded the command should execute.

You can have it export directly to a CSV file by tacking Export-CSV onto the end:

Get-QADGroupMember "ACL Team" | Select-Object Name,Email | Export-CSV -Path "C:\Group\ACL.txt"

Otherwise you will need to construct queries like this for each group:

dsquery * -Filter "(&(objectClass=user)(objectCategory=person)(memberOf=CN=ACL Team,OU=somewhere,DC=yourdomain,DC=com))"  | dsget user -email -display > c:\Group\UsersACL.txt

dsquery * -Filter "(&(objectClass=contact)(objectCategory=person)(memberOf=CN=ACL Team,OU=somewhere,DC=yourdomain,DC=com))"  | dsget contact -email -display > c:\Group\ContactsACL.txt


Featured Post

Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now