intoxicated_curveball
asked on
How to get all emails from ActiveDirectory using PowerShell without using Get-AdGroupMember?
I'm trying to download all emails from AD groups using PowerShell. The following recursive command works for most groups except any with more than 5000 members (including sub-groups).
The following error occurs with the recursive command returning more than 5000 members:
The issue I have is my IT department will not increase the max member allowed to be queried (5000) on the AD web server.
A quick web search will yield the following solution but it is not recursive, and I need it to be recursive to get the emails from the sub groups (as we have many sub-groups).
Is there any other way to download all emails?
Get-AdGroupMember "groupname" -recursive | Get-AdUser -properties Emailaddress | Select EmailAddress | Export-Csv c:\list.csv
The following error occurs with the recursive command returning more than 5000 members:
Get-ADGroupMember : The size limit for this request was exceeded.
The issue I have is my IT department will not increase the max member allowed to be queried (5000) on the AD web server.
A quick web search will yield the following solution but it is not recursive, and I need it to be recursive to get the emails from the sub groups (as we have many sub-groups).
$grp = get-adgroup "groupname" -properties members
$grp.members | get-aduser | Select Name | Export-csv C:list.csv
Is there any other way to download all emails?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Subsun, worked great! Minor issue: it does return duplicates (from sub-groups, not a big deal). Is there anyway to prevent duplicates initially so it doesn't have to be done post-processing?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window