Solved

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

Posted on 2016-10-24
3
26 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
Comment Utility
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 82

Accepted Solution

by:
oBdA earned 500 total points
Comment Utility
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
Comment Utility
The Powershell script did exactly what I wanted so I am accepting this comment as the answer.
Thanks!
Don
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
Set OWA language and time zone in Exchange for individuals, all users or per database.
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
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…

744 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