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

Next

Set oFilesys = CreateObject("Scripting.FilesystemObject")
Set oFiletxt = oFilesys.CreateTextFile("Pathtotextfile", True)
sPath = oFilesys.GetAbsolutePathName("Pathtotextfile")

sFilename= oFilesys.GetFileName(sPath)

oFiletxt.WriteLine(strMbrs)

oFiletxt.Close

'If you also want to see the users in a prompt enable following line

'Wscript.Echo strMbrs

Hope I didn’t type any errors, had to manually write it :s

By admin

Former Freehand Freelance Graphic Illustrator... been online since 2004 ( late starter ), blogging since 2005, presently writing a suspense-thriller e-book that began as a screenplay.

Leave a Reply

Your email address will not be published. Required fields are marked *