Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 57
  • Last Modified:

Count how many active directory group members for more than one AD group

Hi EE

Wondering if anyone has had the need to report on how many group members exist for certain AD groups.  I need to set a task to report the total amount of AD group members for five groups and wanted to see if anyone had a PS script they can share.

The ideal output would be the total amount of users and group name .
0
MilesLogan
Asked:
MilesLogan
1 Solution
 
SubsunCommented:
If it's just member count then you can use following code..

C:\group.txt should contain the group names which you want to lookup.
Import-Module Activedirectory
GC C:\group.txt | %{
	New-Object PSobject -Property @{
	Group = $_
	UserCount = (Get-ADGroupMember $_ -Recursive | Measure).Count
	}
}| Select Group,UserCount

Open in new window

0
 
MilesLoganAuthor Commented:
Awesome ! thanks man , have a good weekend .
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now