ORIGINALLY POSTED BY CEMETRIC FOR THETAZZONE/TAZFORUM HERE
Do not use, republish, in whole or in part, without the consent of the Author. TheTAZZone policy is that Authors retain the rights to the work they submit and/or post…we do not sell, publish, transmit, or have the right to give permission for such…TheTAZZone merely retains the right to use, retain, and publish submitted work within it’s Network
Please refer to the original post as not all the script may be visible here.
Enumerate the users of a AD Group. Very easy script, but can come in handy sometimes, save from having to use Users & Computers, also it will write the list of users to a file you can specify. You could make the script easier to use if you implement a prompt for entering the groupname you want to enumerate.
- Code: Select all
strDom = "DomainName"
strGrp = "GroupName"
strMbrs = "Members of: " & strGrp & vbCRLF
set objDom = GetObject("WinNT://" & strDom & "/" & strGrp)
for each objMbr in objDom.Members
strMbrs = strMbrs & objMbr.FullName & " (" & objMbr.Class &")" & vbCRLF
Set oFilesys = CreateObject("Scripting.FilesystemObject")
Set oFiletxt = oFilesys.CreateTextFile("Pathtotextfile", True)
sPath = oFilesys.GetAbsolutePathName("Pathtotextfile")
'If you also want to see the users in a prompt enable following line
Hope I didn’t type any errors, had to manually write it :s