TheTAZZone - Internet Chaos

Enumerate the users of a AD Group

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

Leave a Reply

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

Advertise

If you'd like to advertise on The Mutt ( aka TheTAZZone.com ) feel free to contact us at: administration[at]thetazzone.com

TheTAZZone is a non-commercial entity. We do not sell any products or services ourselves. Our revenue comes from advertising and donations only.

We appreciate your support! Your advertising revenue ( or donations ) helps us to continue to upgrade, improve, and offset the costs of maintaining this site.

Donations can be made through the page ' Donate '.