Getting a list of users that belong to a Windows Security Group

Some times it is not always easy to see the name that you are looking for in a GUI list of users that Active Directory Users and Computers displays.  Using VB Scripting you can obtain a list of users from a Security group and output this to screen or to text file.

The code below displays users of the Domain Users group for the Netbios domain NTDOMAIN.

DomainString = "NTDOMAIN"
GroupString = "Domain Users"
Set GroupObj = GetObject("WinNT://"; & DomainString & "/" & GroupString)
For each UserObj in GroupObj.Members
    List = List & UserObj.Name
Wscript.Echo List

Modify the NTDOMAIN string to match your domain or local computer that you wish to get the listing from.  Alter the GroupString to match the security group that you want to look at.

This script can be altered to export data to a text file by using the appropriate code in between the For and Next lines.

For further details of the Microsoft Scripting language use as a starting point.  You can find many more code examples from


Posted in Scripting.