help with dsquery and dsget

Posted on 2009-02-19
Last Modified: 2012-06-27
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

Question by:ccdc12
    LVL 1

    Author Comment

    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 .

    LVL 1

    Author Comment

    can a wild * be used?
    LVL 70

    Accepted Solution


    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

    LVL 16

    Expert Comment

    LVL 1

    Author Comment

    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


    LVL 70

    Expert Comment

    by:Chris Dent

    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


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    I'm sure that every Windows systems administrator has written, or at least used, a batch or VBS login script at some point in their career, whether it is to map network drives, install printers, or set some user preferences.  No more! With Window…
    This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…
    This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now