Need VB Script to find which memeber is in which group?

Hey Scripting Guys,
                      I Need to do a VBscript that exports/pulls the info out off the AD, so i can see wich members are in which Groups.  Anyone can help there. Please ASAP
Mian BabaAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ste5anSenior DeveloperCommented:
ASAP??
Mian BabaAuthor Commented:
I mean i need it as soon as possible.
omgangIT ManagerCommented:
I had this one lying around.  You need to modify the LDAP path for your environment and for the AD Group you with to query.  The script outputs a CSV file into the same directory the script is in.
OM Gang


Option Explicit

Dim arrNames()
Dim intSize, objGroup, strUser, objUser, strHolder, strName, i, j
Dim objFSO, objOutputFile
intSize = 0
 
Set objGroup = GetObject("LDAP://CN=ADGroupName,OU=SubOU,OU=PrimaryOU,DC=root,DC=sub,DC=top")
 
If TypeName(objGroup.Member) = "Empty" Then
	WScript.Echo "There are no members in " & objGroup.Name
ElseIf TypeName(objGroup.Member) = "String" Then
	WScript.Echo objGroup.Member
Else
	For Each strUser in objGroup.Member
	    Set objUser =  GetObject("LDAP://" & strUser)
	   
	    ReDim Preserve arrNames(intSize)
	    arrNames(intSize) = objUser.CN
	    intSize = intSize + 1
	Next
	
	For i = (UBound(arrNames) - 1) to 0 Step -1
	    For j= 0 to i
	        If UCase(arrNames(j)) > UCase(arrNames(j+1)) Then
	            strHolder = arrNames(j+1)
	            arrNames(j+1) = arrNames(j)
	            arrNames(j) = strHolder
	        End If
	    Next
	Next 
	
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objOutputFile = objFSO.CreateTextFile("GroupMembers.csv")
	
	For Each strName in arrNames
	    objOutputFile.WriteLine strName
	Next
	
    objOutputFile.Close
    Set objOutputFile = Nothing
    Set objFSO = Nothing
    Set objUser = Nothing
    Set objGroup = Nothing
    
End If

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
yo_beeDirector of Information TechnologyCommented:
do you need it do be VBS or can you leverage Powershell?

import-module activedirectory

$strUserName = "username"
$strUser = get-aduser  $strUserName -Properties *
$strUser.memberof | Get-ADGroup | Select Name | Export-Csv -Path .\test.csv -NoTypeInformation

Open in new window

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.