Many times I simply need the number of people in an AD group. There are two ways of doing this (and probably a lot more) that I have done this. One way is to define an object and then assign the output of getting the members from a group to the object, and then getting the count of the items in the object.
$users = Get-ADGroupMember -Identity 'VPNUsers'
$users.count
The other manner of doing this is to simply use a filter which is looking for only those members of the group.
Get-ADuser -filter { memberof VPNUsers}.count
Similarly, you get get counts of all other items in AD. Using
(Get-ADUser -Filter * -SearchBase “OU=Users,DC=example,DC=com”).Countwill count all users in teh Users OU. And the following would count the respective objects in the domain.
(Get-ADUser -Filter *).Count (Get-ADGroup -Filter *).Count (Get-ADComputer -Filter *).Count