Quantcast
Channel: Active Directory – wisefaq.com
Viewing all articles
Browse latest Browse all 28

Getting a list of users in a particular AD Group

$
0
0

Get-ADGroup "<GROUP NAME>" -Properties Member | Select-Object -ExpandProperty Member | Get-ADUSer -properties Displayname,Description,EmailAddress | Select Name,Displayname,Description,EmailAddress

will cause the following to display

Name    Displayname   Description   EmailAddress
----    -----------   -----------   ------------
fkjhsd  Fred Smith    Tech Support  naveed.arshad@noddyland.com
fhdfdf  Bill Burke    Manager       bill.burke@noddyland.com
wrfvvv  Alice Cooper  Test account  alice.cooper@noddyland.com

How to output to a file?
Get-ADGroup "<GROUP NAME>" -Properties Member | Select-Object -ExpandProperty Member | Get-ADUSer -properties Displayname,Description,EmailAddress | Select Name,Displayname,Description,EmailAddress |Export-CSV 'c:\data\temp\<GROUP NAME>.csv'

Wouldn’t Get-ADGroupMember be a better choice than Get-ADGroup?
Yes, it would.  If the group is not a large group.  If it has a large number of members, you’ll run into the following error:

get-adgroupmember : The size limit for this request was exceeded

Active Directory has a default retrieval limit of 5000 objects for Get_ADGroupMember (and Get-ADPrincipalGroupMembership, and Get-ADAccountAuthorizationGroup).


Viewing all articles
Browse latest Browse all 28

Trending Articles