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

Active Directory Export Script

I need to export the name of each OU, Security Group and Distribution Groups along with their members names to a text file.  Our domain name is FSS.local and our DC is FSSFS.  Does anyone have a clue how to do this?
1 Solution
at the command line

net users /domain
will get you a list of users

net groups /domain
will get you a list of groups

you can direct them into a text file like this
net users /domain>USERS.TEXT
net groups /domain>>USERS.TEXT
For security group membership, create a batch file that reads:
cscript listgroup.vbs>grouplist.txt

Create a vbs file named "listgroup.vbs" containing:

On Error Resume Next
Set objGroup = GetObject _
  ("LDAP://cn=<groupname>;ou=<path to group>;dc=FSS,dc=local")
arrMemberOf = objGroup.GetEx("member")
WScript.Echo "<groupname>"
For Each strMember in arrMemberOf
  WScript.echo strMember

This will create a file named whatever you put in place of <groupname>. You'd have to do this with each security group or distribution list.
steveLaMiAuthor Commented:
Is there a way to get the users of a distribution group into a text file?
Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

Mike KlineCommented:
I would suggest something like adfind or powershell.  Michael Smith has a good overview of doing this with adfind
In addition to that if you want to export the OUs and their names
adfind -default -f objectcategory=organizationalunit name
steveLaMiAuthor Commented:
Matt... I didnt see your answer before I posted my last comment, I will give it a try
Tony MassaCommented:
Here's a script that will prompt for the DNS domain name, and group name, then put the user info into an Excel spreadsheet.  Note:  Assumes you have Excel installed on the computer you're running it on.
Here is another script which you can use to get all groups and group member details:

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.

Join & Write a Comment

Featured Post

Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

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