I usually get asked a lot for lists, specifically lists of AD users and members of groups etc. There are a couple of methods to obtain this…
Output user list in txt format using CMD:
- net user /domain > C:users.txt (Only Lists Logon Usernames / no OU or Group Info)
Output user list in .txt format (more detail) using VBS:
- Simple VBS Script to printout the AD information
- Text file output to the same folder the script was run from…
- I’ve slightly tweaked this script to make the output data more easy on the eyes.
'******************************************************************** '* '* File: DomainUinfo.vbs '* Created: September 2005 '* Version: 2k510.04 '* '* ' Sample Script For Listing All The User Related Infomations In The Domain. '* '* Main Function: Listing All The User Related Infomations In The Domain. '* '* Syntax Domain Name '* '* Copyright (C) 2005 N Nattiala '* '******************************************************************** ' Description - This portion of the script will attach to the domain using the ' WinNt provider and filter out a list of every computer object's ' name and write them to DomUinfo.txt. If the file already exists it will ' overwrite, otherwise it will create the file. '------------------------------------------------- ' Insert WARNING here... Msgbox " This script will collect all the Computers,Domain User and Group related information and"_ & vbcrlf & vbcrlf & " store in DOMUINFO.TXT. Please input your Domain name according to your environment" _ & vbcrlf & vbcrlf & " Created and Completed By: N Nattiala. ",48,"WARNING" ' Check for the existence of DomUinfo.txt. ' and open for Writing. Dim myComputer, objUser, objGroup Dim myDomain Set fsoObject = WScript.CreateObject("Scripting.FileSystemObject") If (fsoObject.FileExists("DomUinfo.txt")) Then Set open_File = fsoObject.OpenTextFile("DomUinfo.txt", 2) Else Set open_File = fsoObject.OpenTextFile("DomUinfo.txt", 2, "True") End If ' Get Domain Name myDomain = Inputbox ("Please Enter Your Domain Name: "_ & vbcrlf & vbcrlf & " Take Care") 'msgbox" Your Domain Name is :" &mydomain _ '& vbcrlf & vbcrlf &"Do you wish to cancel this Script?",vbYesNo,"Warning" ' Attach to the domain and search for all ' computer objects. Dump the names into ' DomUinfo.txt. Set myComputer = GetObject ( "WinNT://"& mydomain ) myComputer.Filter = Array("computer") For Each item in myComputer open_File.Writeline (item.Name) Next myComputer.Filter = Array("user") For Each objuser in myComputer open_File.Writeline ("User Name: " & objUser.Name & " - Full Name: " & objuser.fullname & " - Description: " & objuser.description) Next myComputer.Filter = Array("group") For Each objGroup In myComputer For Each objUser In objGroup.Members open_File.Writeline ("Group: " & objGroup.Name & " - Username: " & objUser.Name) Next Next ' Closes the file open_File.Close() |