|
Replies:
10
-
Pages:
1
-
Last Post:
May 18, 2010 12:52 PM
by: Greg Westergren
|
Threads:
[
Previous
|
Next
]
|
|
Posts:
29
Registered:
8/12/09
|
|
|
|
Need a powershell comand to pull members of security groups in an OU
Posted:
Sep 1, 2009 7:20 AM
|
|
|
Need a powershell comand to pull members of security groups in an OU. Output the results into a CSV file.
|
|
|
Posts:
22
Registered:
5/27/09
|
|
|
|
Re: Need a powershell comand to pull members of security groups in an OU
Posted:
Sep 1, 2009 8:08 AM
in response to: mmoss1107
|
|
|
How about something like this:
$myCol = @() ForEach ($Group in (Get-QADGroup -SearchRoot "OU=FOO,DC=BAR,DC=local" -SizeLimit 0 -GroupType Security)) { ForEach ($Member in (Get-QADGroupMember $Group)) { $myObj = "" | Select Group, Member $myObj.Group = $Group.Name $myObj.Member = $Member.Name $myCol += $myObj } } $myCol | Export-Csv -Path "D:\scripts\file.csv" -NoTypeInformation
Hugo http://www.peetersonline.nl
|
|
|
Posts:
29
Registered:
8/12/09
|
|
|
|
Re: Need a powershell comand to pull members of security groups in an OU
Posted:
Sep 1, 2009 11:13 AM
in response to: hugopeeters
|
|
|
$myCol = @() ForEach ($Group in (Get-QADGroup -SearchRoot us.test.com/us firm wide/applications/mail/security groups -SizeLimit 0 -GroupType Security)) { ForEach ($Member in (Get-QADGroupMember $Group)) { $myObj = "" | Select Group, Member $myObj.Group = $Group.Name $myObj.Member = $Member.Name $myCol += $myObj } } $myCol | Export-Csv -Path "C:\PS\SGMembers.csv" -NoTypeInformation
Here is the error I recieve.
>> Get-QADGroup : A parameter cannot be found that matches parameter name 'wide/ap plications/mail/security'. At line:1 char:35 + ForEach ($Group in (Get-QADGroup <<<< -SearchRoot us.test.com/us firm wide/applications/mail/security groups -SizeLimit 0 -GroupType Security))
|
|
|
Posts:
414
Registered:
12/15/08
|
|
|
|
Re: Need a powershell comand to pull members of security groups in an OU
Posted:
Sep 1, 2009 11:38 AM
in response to: mmoss1107
|
|
|
You just need to quote your -SearchRoot value:
Get-QADGroup -SearchRoot "us.test.com/us firm wide/applications/mail/security groups" ...
-Chris
|
|
|
Posts:
29
Registered:
8/12/09
|
|
|
|
Re: Need a powershell comand to pull members of security groups in an OU
Posted:
Sep 1, 2009 11:56 AM
in response to: seaJhawk
|
|
|
Does make since that I get this error when the SizeLimit is set to zero.
WARNING: Only first 1000 search results were displayed. To display more, increase size limit using -SizeLimit parameter (use 0 as the value of size limit to display all search results).
|
|
|
Posts:
414
Registered:
12/15/08
|
|
|
|
Re: Need a powershell comand to pull members of security groups in an OU
Posted:
Sep 1, 2009 11:59 AM
in response to: mmoss1107
|
|
|
Nope, that doesn't make sense. Sounds like a typo issue.
Can you repost the script that returned that error?
-Chris
|
|
|
Posts:
29
Registered:
8/12/09
|
|
|
|
Re: Need a powershell comand to pull members of security groups in an OU
Posted:
Sep 1, 2009 12:12 PM
in response to: seaJhawk
|
|
|
$myCol = @() ForEach ($Group in (Get-QADGroup -SearchRoot “us.test.com/us firm wide/applications/mail/security groups” -SizeLimit 0 -GroupType Security)) { ForEach ($Member in (Get-QADGroupMember $Group)) { $myObj = "" | Select Group, Member $myObj.Group = $Group.Name $myObj.Member = $Member.Name $myCol += $myObj } } $myCol | Export-Csv -Path "C:\SGMembers.csv" -NoTypeInformation
|
|
|
Posts:
414
Registered:
12/15/08
|
|
|
|
Re: Need a powershell comand to pull members of security groups in an OU
Posted:
Sep 1, 2009 1:56 PM
in response to: mmoss1107
|
|
|
Out of curiosity, do you have over a thousand security groups in the OU specified?
Everything looks ok to me... Are you running the latest version of the Quest AD cmdlets?
I don't have a single OU with more than a thousand security groups so I can't test with the -searchroot parameter. But if I search at the root of my domain I have over 1000 groups and all of them are returned without the warning.
I am running the latest version of the cmdlets.
-Chris
|
|
|
Posts:
29
Registered:
8/12/09
|
|
|
|
Re: Need a powershell comand to pull members of security groups in an OU
Posted:
Sep 1, 2009 3:07 PM
in response to: seaJhawk
|
|
|
889 security groups
|
|
|
Posts:
414
Registered:
12/15/08
|
|
|
|
Re: Need a powershell comand to pull members of security groups in an OU
Posted:
Sep 2, 2009 1:24 PM
in response to: mmoss1107
|
|
|
I can't think of any reason you would get the limit warning.
Did you check the version of the AD cmdlets you're running?
|
|
|
Posts:
11
Registered:
9/17/09
|
|
|
|
Re: Need a powershell comand to pull members of security groups in an OU
Posted:
May 18, 2010 12:46 PM
in response to: seaJhawk
|
|
|
Scratch that....it just took a bit longer to pop up.
I ran it with -sizelimit 0 after Get-QADGroup like this and didn't get the error.
$myCol = @() ForEach ($Group in (Get-QADGroup -SizeLimit 0 -SearchRoot "" -GroupType Security)) { ForEach ($Member in (Get-QADGroupMember $Group)) { $myObj = "" | Select Group, Member $myObj.Group = $Group.Name $myObj.Member = $Member.Name $myCol += $myObj } } Message was edited by: Greg Westergren
Message was edited by: Greg Westergren
|
|
|
|
Legend
|
|
MVP: 2501
+
pts
|
|
Guru: 2001
- 2500
pts
|
|
Expert: 751
- 2000
pts
|
|
Enthusiast: 31
- 750
pts
|
|
Novice: 0
- 30
pts
|
|
Moderators
|
|
Helpful answer
(5 pts)
|
|
Answered
(10 pts)
|
|