Link to home
Start Free TrialLog in
Avatar of georgemihailovski
georgemihailovski

asked on

Export full name and username for each user with a vbs script

Hello all,

I require some assistance in modifying the vbs script attached.

The script at the moment will export all users that belong to a specific Active Directory group.

How can I modify this script to also export the user's login name?

Your assistance would be most appreciated.
'Script begins here
Dim objGroup, objUser, objFSO, objFile, strDomain, strGroup, Domain, Group
'Change DomainName to the name of the domain the group is in
strDomain = Inputbox ("Enter the Domain name", "Data needed", "Default domain name")
'Change GroupName to the name of the group whose members you want to export
strGroup = InputBox ("Enter the Group name", "Data needed", "Default group name")
Set objFSO = CreateObject("Scripting.FileSystemObject")
'On the next line change the name and path of the file that export data will be written to.
Set objFile = objFSO.CreateTextFile("C:\" & strGroup & " - Members.txt")
Set objGroup = GetObject("WinNT://" & strDomain & "/" & strGroup & ",group")
For Each objUser In objGroup.Members
    objFile.WriteLine objUser.FullName & " - " & objUser.Class
Next
objFile.Close
Set objFile = Nothing
Set objFSO = Nothing
Set objUser = Nothing
Set objGroup = Nothing
Wscript.Echo "Done - Please check the c: for your output file"

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of RobSampson
RobSampson
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
WINNT is limited to the attributes you can collect.
With what you are looking for you will be fine, but if you want to get more detail and deeper into scripting to Create, Gather and Update I like to use LDAP:// rather than WINNT://