Stan
 New Member Posts:13

 |
| 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
|
|
|
|
|
seaJhawk
 Basic Member Posts:191

 |
| 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 |
|
|
|
|
Stan
 New Member Posts:13

 |
| 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. |
|
|
|
|
seaJhawk
 Basic Member Posts:191

 |
| 13 Nov 2009 01:48 PM |
|
actually you need to use -sizelimit 0 to return all results. |
|
|
|
|
Stan
 New Member Posts:13

 |
| 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 Levy PowerShell MVP, Admin
 Veteran Member Posts:1362

 |
| 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 Ramnani
 New Member Posts:68

 |
| 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 |
|
|
Stan
 New Member Posts:13

 |
| 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 Levy PowerShell MVP, Admin
 Veteran Member Posts:1362

 |
| 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 |
|
|
Stan
 New Member Posts:13

 |
| 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. |
|
|
|
|