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…

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
Next
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 www.microsoft.com/scripting as a starting point.  You can find many more code examples from cwashington.netreach.net.

 

Similar Posts

  • Adding a Domain Account to a local security group

    Windows Scripting Host is a very powerful tool that allows you to use simple Visual Basic code syntax to change or customise settings of a computer.  This script will allow you to use Window Active Directory Group Policy to add a domain user account or group to a local security group of a Windows 2000/XP…

  • Remove all profiles on startup

    Occasionally Windows XP manages to stuff up its roaming profile, when this happens, resolving profile related problems can be difficult.  Schools running Community Connect 3 will benefit from the “Reset Profile” option in the System Management Console, however, profile problems may quickly return, as they often remain on several workstations. To help cure this problem…

  • Script to delete files after x days

    Have you ever needed to automate the cleaning of a folder that say is used as part of a backup or just as a dumping ground.  Using this script will help you to speed up the cleaning process by deleting files from any folder or UNC path that are older than the specified (x) days.