I use this one quite a lot because people always want to know who all is in an Active Directory Group. Here is my quick and ugly Powershell script to find this info.
$ldap = “your ldap path here“
$de = new-object directoryservices.directoryentry(“LDAP://” + $ldap)
$ds = new-object directoryservices.directorysearcher($de)
$ds.filter = ‘(&(samaccountname=*))’
$rc = $ds.findall()
$rc[0].properties(‘member’)
A more quick and less ugly way would have been:
Get-QADGroupMember mygroup
Thanks for the comment. I should be clear that I am using Powershell v1.0 without any addins. The AD oneliners seem to require an additional install?
That command uses the free Quest AD cmdlets.
If you want to get the groupmembers recursively (so including the members of groups that are a member of the group and so on), take a look at the following script. It even generates a nice tree view of the users and groups found:
http://www.peetersonline.nl/index.php/powershell/listing-ad-group-members-recursively-with-powershell/
Hugo
(get-group -Identity nameofgroup ).members
with EMC