Announcement

Collapse
No announcement yet.

Export members of a distribution group to text file - help please

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Export members of a distribution group to text file - help please

    Hi All

    I need a bit of help using dsquery and dsget to extract all users in a specific distribution group.

    Here is the location of the distribtution group in AD.
    Test.com>Distribution Groups>Replicated>IT Team

    So the distribution group is called IT Team and what I want to be able to do is export to a text file the names of all users who belong to this group.

    I have tried many variations such as:
    dsquery group "ou=replicated, ou=distribution groups, dc=test, dc=com" | dsget -members >users.txt

    But nothing seems to work.

    Would really appreciate some help on this and it would also help me understand these two commands better perhaps.

    Many thanks in advance.

    DC

  • #2
    Re: Export members of a distribution group to text file - help please

    If you have PowerShell available, try the command:
    Get-ADGroupMember "Replicated" | ft name,samaccountname | Export-Csv "C:\Scripts\GroupMembers.csv"

    (from http://kc-tek.blogspot.co.uk/2011/10...-ad-group.html)
    Tom Jones
    MCT, MCSE (2000:Security & 2003), MCSA:Security & Messaging, MCDBA, MCDST, MCITP(EA, EMA, SA, EDA, ES, CS), MCTS, MCP, Sec+
    PhD, MSc, FIAP, MIITT
    IT Trainer / Consultant
    Ossian Ltd
    Scotland

    ** Remember to give credit where credit is due and leave reputation points where appropriate **

    Comment


    • #3
      Re: Export members of a distribution group to text file - help please

      Hi Ossian

      Thanks for getting back to me, unfortunately we don't have Powershell and I've been asked to use dsquery and dsget in CMD to carry out this task.

      Is this possible?

      Comment


      • #4
        Re: Export members of a distribution group to text file - help please

        No reason why not, but its been a long time since I used both

        Suggest you test your command step by step and see where it breaks down

        Looks as if you have an example here:
        http://social.technet.microsoft.com/...d-f659b48f6f98
        and here:
        http://oasysadmin.com/2012/01/06/exp...o-a-text-file/
        Tom Jones
        MCT, MCSE (2000:Security & 2003), MCSA:Security & Messaging, MCDBA, MCDST, MCITP(EA, EMA, SA, EDA, ES, CS), MCTS, MCP, Sec+
        PhD, MSc, FIAP, MIITT
        IT Trainer / Consultant
        Ossian Ltd
        Scotland

        ** Remember to give credit where credit is due and leave reputation points where appropriate **

        Comment


        • #5
          Re: Export members of a distribution group to text file - help please

          You can do this with dsquery and dsget:


          Code:
          dsquery group -name "IT Team" | dsget group -members
          Rules of life:
          1. Never do anything that requires thinking after 2:30 PM
          2. Simplicity is godliness
          3. Scale with extreme prejudice


          I occasionally post using a savantphone, so please don't laugh too hard at the typos...

          Comment


          • #6
            Re: Export members of a distribution group to text file - help please

            Originally posted by Dead Cell View Post

            Here is the location of the distribtution group in AD.
            Test.com>Distribution Groups>Replicated>IT Team
            "cn=IT Team,ou=replicated,ou=distribution groups,dc=test,dc=com"

            So the distribution group is called IT Team and what I want to be able to do is export to a text file the names of all users who belong to this group.
            Code:
            Dsget.exe GROUP "cn=IT Team,ou=replicated,ou=distribution groups,dc=test,dc=com" -members >"users.txt" 2>&1
            OR
            Code:
            Dsget.exe GROUP "cn=IT Team,ou=replicated,ou=distribution groups,dc=test,dc=com" -members | Dsget.exe USER -samid -display >"users.txt" 2>&1
            /Rems

            This posting is provided "AS IS" with no warranties, and confers no rights.

            __________________

            ** Remember to give credit where credit's due **
            and leave Reputation Points for meaningful posts

            Comment

            Working...
            X