arrow    Home arrow Knowledge Base arrow Scripting arrow Getting a list of users that belong to a Windows Security Group
Site Areas
Home
News
Knowledge Base
Web Links
Contact Us
Files
Terms of Use
Profile





Lost Password?
No account yet? Register
Getting a list of users that belong to a Windows Security Group
Written by Terry Watts   
Sunday, 09 October 2005

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.

 

 
go to top Go To Top go to top
This article has been printed from www.schooltechnician.co.uk and is protected under copyright.
See http://www.schooltechnician.co.uk/terms_of_use.html for further details.