From our Active Directory, in Users and Computers, in my Groups folder.
I have many groups that I would like to extract the users names from
and try to avoid going group to group to extract each name manually.
Is there a way to automate or script this information extraction?
Being a scripting nut, I tend to approach these kind of problems from a scripting standpoint.
copy and paste the code below into "Mattisastud.vbs" and then run it.
Then open the GroupMembership.txt file and it should have everything you need.
If you want to view the machine accounts also, uncomment the commmented line...
Dim myNetwork
Set myNetwork = CreateObject("Wscript.Network")
strDomain = myNetwork.UserDomain
Set objDomain = getobject("WinNT://" & strDomain) 'Grab the domain object
objDomain.filter = Array("Group") 'Filter for just computers.
Dim myFSO
Set myFSO = CreateObject("Scripting.FileSystemObject")
Set myFile = myFSO.CreateTextFile("GroupMembership.txt",1)
myOutput = ""
For each objGroup in objDomain
myOutput = myOutput & objGroup.Name & vbcrlf
For Each objUser in objGroup.Members
' myOutput = myOutput & vbtab & objUser.Name & vbcrlf
If right(objUser.name,1) <> "$" Then
myOutput = myOutput & vbtab & objUser.Name & vbcrlf
End if
Next
Next
WScript.Echo myOutput
myfile.writeline myOutput
-=-=-=-=-=-=-=-=-=-=-=-=-=- End Code -=-=-=-=-=-=-=-=-=-=-=-=-=-
From https://www.experts-exchange.com/questions/20698009/Exports-Group-list-to-a-text-file.html#9073544
Being a scripting nut, I tend to approach these kind of problems from a scripting standpoint.
copy and paste the code below into "Mattisastud.vbs" and then run it.
Then open the GroupMembership.txt file and it should have everything you need.
If you want to view the machine accounts also, uncomment the commmented line...
-=-=-=-=-=-=-=-=-=-=-=-=-=
Dim myNetwork
Set myNetwork = CreateObject("Wscript.Netw
strDomain = myNetwork.UserDomain
Set objDomain = getobject("WinNT://" & strDomain) 'Grab the domain object
objDomain.filter = Array("Group") 'Filter for just computers.
Dim myFSO
Set myFSO = CreateObject("Scripting.Fi
Set myFile = myFSO.CreateTextFile("Grou
myOutput = ""
For each objGroup in objDomain
myOutput = myOutput & objGroup.Name & vbcrlf
For Each objUser in objGroup.Members
' myOutput = myOutput & vbtab & objUser.Name & vbcrlf
If right(objUser.name,1) <> "$" Then
myOutput = myOutput & vbtab & objUser.Name & vbcrlf
End if
Next
Next
WScript.Echo myOutput
myfile.writeline myOutput
-=-=-=-=-=-=-=-=-=-=-=-=-=
CREDIT To :MAT
*****Other Links*****
How can I create a file containing all the user names in my domain?
http://www.jsiinc.com/subl/tip5500/rh5531.htm
How can I produce a list of the user logon names in my domain?
http://www.jsiinc.com/subi/tip4400/rh4490.htm
Run a Group/User or User/Group report.
http://www.jsiinc.com/SUBB/tip0700/rh0748.htm