Powershell : Count Members of a AD Group

May 31, 2016

4 comments

Powershell : Count Members of a AD Group

As System Administrator, In many cases you need to count members of AD group.

The Get-ADGroupMember cmdlet gets the members of an Active Directory group. Members can be users, groups, and computers.

Code:

$users = Get-ADGroupMember -Identity 'Group Name'
$users.count
132

2016-07-17 11_54_56-Administrator_ Windows PowerShell

Add comment
facebook linkedin twitter email

Leave a Reply to Mehul Gavit Cancel Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.

4 comments

  1. JoHnD0xDecember 19, 2017 ב 12:26 PM

    This works but theres a further issue created when members of the group are infact more groups… Is there a way to then count the users within those in the same script. i.e. count the members and members of subgroups?

    Reply
  2. Mehul GavitDecember 30, 2017 ב 7:14 AM

    Hi Team,

    it shows, distinguishedName, name, objectClass, objectGUID, SamAccountName, SID.

    If I want to display only Name then which switch i’ve to use.

    Thank You.

    Reply
    1. Haim Cohen
      Haim CohenSeptember 3, 2018 ב 2:16 PM

      just pipe and filter

      e.g.

      $users = Get-ADGroupMember -Identity ‘Group Name’
      $users | ft name

      Reply
  3. Gareth DaviesMarch 13, 2018 ב 6:53 PM

    (Get-ADGroupMember -Identity ‘Domain Admins’).count

    Reply