Query AD group membership with Powershell

Here are a couple of very useful scriptlets if you ever need to enumerate or count the quantity of users in an AD group.

To list the users in a group try this:

 Get-QADGroupMember -SizeLimit 0 'my group'

To just return the quantity of users in a group try this:

Get-QADGroupMember -SizeLimit 0 'my group' | Measure-Object

I’m using the Quest Addin for AD which comes with (the excellent) PowerGUI IDE or can be downloaded from here.

If you have it installed but are getting errors about the command not be recognised then you need to import the snappin first:

Add-PSSnapin Quest.ActiveRoles.ADManagement

Thanks.

 

Posted on October 25, 2012 at 14:47 by simon · Permalink
In: AD, Power Shell

Leave a Reply