header1   header
header
header Register : : Login header
header
connector   connector
menuleft menuright
submenu   submenu
left
Group Members per OU
Last Post 04 Dec 2009 01:07 PM by Stan. 9 Replies.
Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
StanUser is Offline
New Member
New Member
Posts:13
Avatar

--
13 Nov 2009 11:04 AM
    Hello all -

    I am trying to write a script that will be me group membership of a group which is then broken down by OU.

    I can get the group membership of a group using this

    Get-QADGroupMember -IncludedProperties members | select name,samaccountname.

    This will give me the members of a specific group, now i want to limit this to members of a specific OU.  Can anyone help me out with this?

    Thank you,

    Stanley
    seaJhawkUser is Offline
    Basic Member
    Basic Member
    Posts:191
    Avatar

    --
    13 Nov 2009 11:57 AM
    Hi Stanley,

    Try this:

    Get-QADGroupMember | where{$_.dn -match "ou=user,dc=domain,dc=com"} | select name,samaccountname

    -Chris
    StanUser is Offline
    New Member
    New Member
    Posts:13
    Avatar

    --
    13 Nov 2009 12:37 PM
    This worked, but only partially. I went into ADUC to verify that this caught everyone under these parameters and not everyone who is a member of the OU and group were produced by PS. Any thoughts as to why is only brought back a partial list. I was thinking maybe it was a sizelimit issue. So i added -sizelimit 1000 before the pipe command to this, but am still only seeing partial results.
    seaJhawkUser is Offline
    Basic Member
    Basic Member
    Posts:191
    Avatar

    --
    13 Nov 2009 01:48 PM
    actually you need to use -sizelimit 0 to return all results.
    StanUser is Offline
    New Member
    New Member
    Posts:13
    Avatar

    --
    13 Nov 2009 02:36 PM
    Ok, I tired it and still got the same number of results as previously. So I don't necessarily thinks its a size limit issue.
    Shay LevyUser is Offline
    PowerShell MVP, Admin
    Veteran Member
    Veteran Member
    Posts:1362
    Avatar

    --
    14 Nov 2009 12:06 PM
    Try this:

    Get-QADGroup -SizeLimit 0 -SearchRoot | Foreach-object{
    $g = $_.name
    Get-QADGroupMember $g -SizeLimit 0 | Select name,samaccountname,@{n="GroupName";e={$g}}
    }

    Shay Levy
    Windows PowerShell MVP
    http://PowerShay.com
    PowerShell Community Toolbar
    Twitter: @ShayLevy
    Vishal RamnaniUser is Offline
    New Member
    New Member
    Posts:68
    Avatar

    --
    16 Nov 2009 03:30 AM
    Please correct this if i am wrong here. You want to enumerate the members of a particular group further divided in different OUs. if so, please try below.

    Get-QADgroup -id "GroupName" | Get-QADGroupMember | Group-Object -Property parentcontainer | ft Name, @{l="UsersInOU";e={$_.group}} -auto


    Exporting it to CSV.

    Get-QADgroup -id "GroupName" | Get-QADGroupMember | Group-Object -Property parentcontainer | select Name, @{n="UsersInOU";e={$_.group}} | Export-CSV c:\groupmembers.csv

    Hope this helps.
    Thanks.
    Vishal Ramnani
    MCITP - Exchange 2007, MCSE Messaging, MCTS - Win 2008 Config
    StanUser is Offline
    New Member
    New Member
    Posts:13
    Avatar

    --
    17 Nov 2009 12:51 PM
    Shay/Vishal,

    Thank you for the suggestions, but I think I am doing something wrong, because I typed each of these command separately and they error out.

    Shay, I am getting a unexpected toke error after the get-qadgroupmember command

    Vishal, with your string i am getting the following error message. "The value for the property AttributScopeQuery cannot be set" This is also appearing after the get-qadgroupmemeber command.
    Shay LevyUser is Offline
    PowerShell MVP, Admin
    Veteran Member
    Veteran Member
    Posts:1362
    Avatar

    --
    21 Nov 2009 01:17 PM
    I can't test right now, how about this version:

    Get-QADGroup -SizeLimit 0 -SearchRoot | Foreach-object{
    $g = $_
    Get-QADGroupMember $g -SizeLimit 0 | Select name,samaccountname,@{n="GroupName";e={ $($g.name) }}
    }

    Shay Levy
    Windows PowerShell MVP
    http://PowerShay.com
    PowerShell Community Toolbar
    Twitter: @ShayLevy
    StanUser is Offline
    New Member
    New Member
    Posts:13
    Avatar

    --
    04 Dec 2009 01:07 PM
    I haven't had a chance to try this yet, but I will let you know when I do.
    You are not authorized to post a reply.


    Active Forums 4.3
    right
    footer   footer
    footer Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 R2 footer
    footer   footer