Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - List all Group Users in AD

Reply
 
Old 08-29-2008   #1 (permalink)
Chris


 
 

List all Group Users in AD

I'm having problems (most of which are being new to powershell!) in grabbing
a list of all groups-users in a domain.

I have played a bit w/ Quest's Active Directoy cmdlets and came up w/ the
following:
get-qadgroup |
foreach-object {get-qadgroupmember ($_)}

This, techncially does what it is suppose to do.... For every group, it
lists the members. But, the problem is, it doesn't state the group name!!

I simple need to get a dump from AD off all group and memberships.

Thanks!

My System SpecsSystem Spec
Old 08-29-2008   #2 (permalink)
RichS [MVP]


 
 

RE: List all Group Users in AD

I haven't got access to an AD to test it but I think that all you need to do
is make a slight modification

get-qadgroup | foreach-object {
"`nGroup: $($_.name)"
get-qadgroupmember ($_)
}

If name doesn't work try distinguishedname

--
Richard Siddaway
All scripts are supplied "as is" and with no warranty
PowerShell MVP
Blog: http://richardsiddaway.spaces.live.com/
PowerShell User Group: http://www.get-psuguk.org.uk


"Chris" wrote:
Quote:

> I'm having problems (most of which are being new to powershell!) in grabbing
> a list of all groups-users in a domain.
>
> I have played a bit w/ Quest's Active Directoy cmdlets and came up w/ the
> following:
> get-qadgroup |
> foreach-object {get-qadgroupmember ($_)}
>
> This, techncially does what it is suppose to do.... For every group, it
> lists the members. But, the problem is, it doesn't state the group name!!
>
> I simple need to get a dump from AD off all group and memberships.
>
> Thanks!
My System SpecsSystem Spec
Old 08-29-2008   #3 (permalink)
Chris


 
 

RE: List all Group Users in AD

Awesome. I'm almost there I think.... I figured it was my lack for
formatting output that was the hiccup......(again, I'm new ..)

But, how would you state the group per line rather than all in one column?
So, it would like similar...
Domain Admin, Chris
Domain Admin, Joe
SQL_Group, Al
SQL_Group,Chris
Blah,blah


Thanks again for the help!!!




"RichS [MVP]" wrote:
Quote:

> I haven't got access to an AD to test it but I think that all you need to do
> is make a slight modification
>
> get-qadgroup | foreach-object {
> "`nGroup: $($_.name)"
> get-qadgroupmember ($_)
> }
>
> If name doesn't work try distinguishedname
>
> --
> Richard Siddaway
> All scripts are supplied "as is" and with no warranty
> PowerShell MVP
> Blog: http://richardsiddaway.spaces.live.com/
> PowerShell User Group: http://www.get-psuguk.org.uk
>
>
> "Chris" wrote:
>
Quote:

> > I'm having problems (most of which are being new to powershell!) in grabbing
> > a list of all groups-users in a domain.
> >
> > I have played a bit w/ Quest's Active Directoy cmdlets and came up w/ the
> > following:
> > get-qadgroup |
> > foreach-object {get-qadgroupmember ($_)}
> >
> > This, techncially does what it is suppose to do.... For every group, it
> > lists the members. But, the problem is, it doesn't state the group name!!
> >
> > I simple need to get a dump from AD off all group and memberships.
> >
> > Thanks!
My System SpecsSystem Spec
Old 08-30-2008   #4 (permalink)
RichS [MVP]


 
 

RE: List all Group Users in AD

Try this


$names = @()
Get-QADGroup | ForEach-Object {
$temp = "`n$($_.Name): "
if ($_.member -ne $null) {
foreach ($user in $_.member){
$un = $user.Split(",")
$temp += $un[0].Replace("CN=","") + ", "
}
$names += $temp.TrimEnd(", ")
}
else {$names += ($temp + "No members")}
}
$names


--
Richard Siddaway
All scripts are supplied "as is" and with no warranty
PowerShell MVP
Blog: http://richardsiddaway.spaces.live.com/
PowerShell User Group: http://www.get-psuguk.org.uk


"Chris" wrote:
Quote:

> Awesome. I'm almost there I think.... I figured it was my lack for
> formatting output that was the hiccup......(again, I'm new ..)
>
> But, how would you state the group per line rather than all in one column?
> So, it would like similar...
> Domain Admin, Chris
> Domain Admin, Joe
> SQL_Group, Al
> SQL_Group,Chris
> Blah,blah
>
>
> Thanks again for the help!!!
>
>
>
>
> "RichS [MVP]" wrote:
>
Quote:

> > I haven't got access to an AD to test it but I think that all you need to do
> > is make a slight modification
> >
> > get-qadgroup | foreach-object {
> > "`nGroup: $($_.name)"
> > get-qadgroupmember ($_)
> > }
> >
> > If name doesn't work try distinguishedname
> >
> > --
> > Richard Siddaway
> > All scripts are supplied "as is" and with no warranty
> > PowerShell MVP
> > Blog: http://richardsiddaway.spaces.live.com/
> > PowerShell User Group: http://www.get-psuguk.org.uk
> >
> >
> > "Chris" wrote:
> >
Quote:

> > > I'm having problems (most of which are being new to powershell!) in grabbing
> > > a list of all groups-users in a domain.
> > >
> > > I have played a bit w/ Quest's Active Directoy cmdlets and came up w/ the
> > > following:
> > > get-qadgroup |
> > > foreach-object {get-qadgroupmember ($_)}
> > >
> > > This, techncially does what it is suppose to do.... For every group, it
> > > lists the members. But, the problem is, it doesn't state the group name!!
> > >
> > > I simple need to get a dump from AD off all group and memberships.
> > >
> > > Thanks!
My System SpecsSystem Spec
Old 08-31-2008   #5 (permalink)
Shay Levy [MVP]


 
 

Re: List all Group Users in AD

Hello chris,


Here's another way (one line):

PS > Get-QADGroup -sizeLimit 0 | select @{name="GroupName";expression={$_.name}}
-expand members | select GroupName,@{n='Member';e={ (Get-QADObject $_).name
}}

GroupName Member
--------- ------
Group1 User1
Group1 User1
Group2 User2
Group2 User2
Group3 User3
Group3 User3


---
Shay Levy
Windows PowerShell MVP
http://blogs.microsoft.co.il/blogs/ScriptFanatic

c> I'm having problems (most of which are being new to powershell!) in
c> grabbing a list of all groups-users in a domain.
c>
c> I have played a bit w/ Quest's Active Directoy cmdlets and came up w/
c> the
c> following:
c> get-qadgroup |
c> foreach-object {get-qadgroupmember ($_)}
c> This, techncially does what it is suppose to do.... For every group,
c> it lists the members. But, the problem is, it doesn't state the
c> group name!!
c>
c> I simple need to get a dump from AD off all group and memberships.
c>
c> Thanks!
c>


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
list users, NOT members of a group PowerShell
Problem copying list of contacts into a new group list Vista mail
No users in Local Administrators Group Vista security
Re: List all Group Users in AD PowerShell
list users in a local group on a distant computer PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46