Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

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

Posted on 2011-10-06
2
Medium Priority
?
1,047 Views
Last Modified: 2012-05-12
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

0
Comment
Question by:georgemihailovski
2 Comments
 
LVL 65

Accepted Solution

by:
RobSampson earned 2000 total points
ID: 36928413
Hi, just change
       objFile.WriteLine objUser.FullName & " - " & objUser.Class

to
       objFile.WriteLine objUser.Name & " - " & objUser.FullName & " - " & objUser.Class

Regards,

Rob.
0
 
LVL 24

Expert Comment

by:yo_bee
ID: 36928488
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://

0

Featured Post

Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Compliance and data security require steps be taken to prevent unauthorized users from copying data.  Here's one method to prevent data theft via USB drives (and writable optical media).
Transferring FSMO roles is done when an admin wants to split roles between certain Domain Controllers or the Domain Controller holding the Roles has been forcefully demoted using dcpromo / forceremoval
This tutorial will walk an individual through the steps necessary to install and configure the Windows Server Backup Utility. Directly connect an external storage device such as a USB drive, or CD\DVD burner: If the device is a USB drive, ensure i…
This tutorial will show how to configure a new Backup Exec 2012 server and move an existing database to that server with the use of the BEUtility. Install Backup Exec 2012 on the new server and apply all of the latest hotfixes and service packs. The…

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question