How To Count The Number Of Objects In A Security Group – PowerShell Script

IT Support Forum Forums Active Directory Users And Computers How To Count The Number Of Objects In A Security Group – PowerShell Script

This topic contains 0 replies, has 1 voice, and was last updated by  Webmaster 1 year, 10 months ago.

  • Author
    Posts
  • #1037

    Webmaster
    Keymaster

    Today a colleague and I had a competition to write a script to count the number of users in an AD security group. My colleague made a PowerShell script to count the users in the group, while I worked on a command line script using dsquery. I finished first, but only because I found a copy of a script I made before. Here’s the PowerShell script:

    (Get-ADGroupMember -identity “domain admins”).count

    The PowerShell script was much better than mine, because my script outputted the users in a group into a CSV, which I then opened in Microsoft Excel and counted the number of rows.

You must be logged in to reply to this topic.