0

I need to extract the name and mobile of all users in an AD group that consists of more than 5000 members.

When I previously did this I only had to extract the name, and this code solved my problem

Get-ADGroup 'xxx' -Properties Member | Select-Object -ExpandProperty Member | Sort Get-ADGroup "xxx" -Properties Member | Select-Object -ExpandProperty Member | Get-ADObject | Select Name | Sort Name ((Get-ADGroup "xxx" -Properties member).member).count Get-ADGroup "xxx" -Properties Member | Select-Object -ExpandProperty Member | Get-ADObject | Select Name | Sort Name | Export-Csv C:\temp\exportmembers.csv -Encoding UTF8 -NoTypeInformation 

Since groups don't contain the property "mobile" I'm unsure how to go about this.

Any help is appreciated.

0

1 Answer 1

1

You can get all group members directly using Get-ADGroupMember, even with subgroups

get-adgroup 'xxxx' |Get-ADGroupMember -Recursive | get-aduser -Properties name,mobile |sort name |select name,mobile | Export-Csv C:\temp\exportmembers.csv -Encoding UTF8 -NoTypeInformation 

For the +5000 member issue, just add the property to Get-AdObject and Select-Object

Get-ADGroup "xxx" -Properties Member | Select-Object -ExpandProperty Member | Get-ADObject -Properties mobile | Select Name,mobile | Sort Name | Export-Csv C:\temp\exportmembers.csv -Encoding UTF8 -NoTypeInformation 
2
  • Thanks for the reply, but because there's more than 5000 members in the group I get an error saying "Get-ADGroupMember : The size limit for this request was exceeded". When I googled I found that the cap is 5000 members for ADGroupMember, which is why I included that in the OP. Any chance you know how to get around this? Commented Mar 3, 2023 at 10:46
  • @Lars see my edit Commented Mar 3, 2023 at 10:53

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.