Solved

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

Posted on 2016-10-24
3
41 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 39

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 84

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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
A brief introduction to what I consider to be the best editor for PowerShell.
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …
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 …

830 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