Solved

Powershell AD Group Membership Query

Posted on 2014-02-26
2
403 Views
Last Modified: 2014-02-27
I am looking to create a Powershell script that will export group name and user name then import this into a SQL table.  Need the export to be formatted with 2 columns GroupName and UserName.  Also need to be able to select multiple groups (as I don't want to export all the groups just 5 or so specific ones) I have found many export samples but none that will give me groupname and username side by side
0
Comment
Question by:geohixon
[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
2 Comments
 
LVL 14

Accepted Solution

by:
Justin Yeung earned 500 total points
ID: 39890305
$OU = "Your AD OU"
$ExportPath = "Your Path"
$Groups = Get-Adgroup -Filter * -SearchBase $OU
foreach ($Group in $Groups)
{
$ADGroupMember = Get-ADGroupMember $Group.Name
if ($ADgroupmember.count -ne $null)
{
$EXport = $ADgroupMember | Select-Object Name,@{Name="GroupName"; Expression={$Group.Name}}}
$EXport  | Out-file $ExportPath -Append
}
0
 

Author Closing Comment

by:geohixon
ID: 39891749
Great thank you for your quick response.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
CRON Questins 9 493
Recommendations for a Camera Video and Still OCX Control or Driver for VB6 12 1,041
How Popular is DotNetNuke 1 178
Free Tool to collect documents from a database 3 104
I'd like to talk about something that is near and dear to my heart: build systems. Without them, building software is all about compiling locally, with software versions everywhere. It can be a mess. Today we are going to discuss building a small di…
How many times a day do you open, acknowledge, or close an IT incident? What’s your process? Do you have a process depending on the incident, systems involved, and other factors? New Relic Alerts gives you options for how you interact with notifica…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

734 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