Solved

Powershell or VBScript to export security groups and members in a give Organizational Unit

Posted on 2016-10-24
3
35 Views
Last Modified: 2016-10-25
I want to export the Active Directory Security Groups and their members from a specified Organizational Unit within Active Directory to a .csv file. I would like a Powershell or VB script. I only need the group name and member names (ie. user name or logon name). I imagine this looking like a table with a group name column and a user name column and if there are 20 user in the first group then I get 20 rows where the group name is the same and the user name is different for each row, but if there is a different format, say a column with the group name at the top and the user names below that I suppose that is ok.
0
Comment
Question by:donander
3 Comments
 
LVL 38

Expert Comment

by:Adam Brown
ID: 41857845
Dumpsec will probably meet (and exceed) your needs for this, as well as provide functionality that will help out later: http://www.systemtools.com/somarsoft/
0
 
LVL 83

Accepted Solution

by:
oBdA earned 500 total points
ID: 41858056
Powershell:
$OU = "ou=Groups,ou=Whatever,dc=domain,dc=com"
$Csv = "C:\Temp\MemberList.csv"
Get-ADGroup -Filter * -SearchBase $OU | ForEach-Object {
	$GroupDN = $_.DistinguishedName
	$GroupName = $_.Name
	Get-ADGroupMember -Identity $_.DistinguishedName |
		Select-Object -Property `
			@{Name='GroupName'; Expression={$GroupName}},
			@{Name='GroupDN'; Expression={$GroupDN}},
			Name,
			DistinguishedName,
			ObjectClass
} | Export-Csv -Path $Csv -NoTypeInformation

Open in new window

0
 

Author Closing Comment

by:donander
ID: 41858867
The Powershell script did exactly what I wanted so I am accepting this comment as the answer.
Thanks!
Don
0

Featured Post

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Create and license users in Office 365 in bulk based on a CSV file. A step-by-step guide with PowerShell script examples.
Find out how to use Active Directory data for email signature management in Microsoft Exchange and Office 365.
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…

929 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

8 Experts available now in Live!

Get 1:1 Help Now