Active Directory Export Script

Posted on 2010-09-14
Last Modified: 2012-05-10
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?
Question by:steveLaMi

Expert Comment

ID: 33673789
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

Expert Comment

ID: 33673978
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.

Author Comment

ID: 33673995
Is there a way to get the users of a distribution group into a text file?
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

LVL 57

Expert Comment

by:Mike Kline
ID: 33673996
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

Author Comment

ID: 33674005
Matt... I didnt see your answer before I posted my last comment, I will give it a try
LVL 17

Accepted Solution

Tony Massa earned 500 total points
ID: 33674190
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.

Expert Comment

ID: 33675267
Here is another script which you can use to get all groups and group member details:

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, we will see the basic design consideration while designing a Multi-tenant web application in a simple manner. Though, many frameworks are available in the market to develop a multi - tenant application, but do they provide data, cod…
Synchronize a new Active Directory domain with an existing Office 365 tenant
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 Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

773 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