Avatar of awsnoc
awsnoc asked on

Export Active Directory Group Membership to a file

Hi,

I want to export users of a certain active directory group to a excel or a txt file. I saw this solution on experts exchange which works TOTALLY AWESOME. I just copied and pasted the code and ran it and it did everything for me. The only problem is that the  output only provides me with username, what I can i do to the same script so that I can add Full name, email, phone number etc. If someone can show me that would be really great. Thanks

https://www.experts-exchange.com/Networking/WinNT_Networking/Q_21614887.html

'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.Name & " - " & objUser.Class
Next
objFile.Close
Set objFile = Nothing
Set objFSO = Nothing
Set objUser = Nothing
Set objGroup = Nothing
Wscript.Echo "Done"
Wscript.Echo "Please check the c: for your output file"

Open in new window

VB ScriptVisual Basic ClassicActive Directory

Avatar of undefined
Last Comment
RobSampson

8/22/2022 - Mon
sirbounty

objUser.FullName should get the full name...let me dig up the other properties for you...
sirbounty

See if these don't get you what you're after...
objUser.FullName
objUser.Title
objUser.Department
objUser.Company
objUser.TelephoneNumber
objUser.Office
objUser.mail
ASKER CERTIFIED SOLUTION
RobSampson

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
awsnoc

Thanks for your help
Your help has saved me hundreds of hours of internet surfing.
fblack61
RobSampson

No problem. Thanks for the grade.

Regards,

Rob.