Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2016-10-24
3
Medium Priority
?
53 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 42

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 85

Accepted Solution

by:
oBdA earned 2000 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

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…
Active Directory can easily get cluttered with unused service, user and computer accounts. In this article, I will show you the way I like to implement ADCleanup..
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…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

704 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