Solved

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

Posted on 2016-10-24
3
47 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 40

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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

This article explains the steps required to use the default Photos screensaver to display branding/corporate images
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
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 …

751 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