Question Locked

Print list of members in a security group

0 helpful
9 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Is there a way to print a list of members in a security group?

In active directory I can scroll through the list but how do I manage to get a printed list of all the members in the security group?

9 replies

by boxfiddler Hot topic

http://tinyurl.com/ypv9r

I have been using a little freeware program called filegrabber for years, but couldn't find it (it appears to be shareware now and offer more than just the ability to print the list content of a folder). The above looks similar.

by statykserver

Thanks but that tool is for directories, I'm trying to pull data from active directory.

Cheers

(is hooterville a real place?? if so I need to move there!)

by boxfiddler Hot topic

filegrabber allows me to drag and drop the contents of a folder into a simple text editor where I then clean out the path parts I don't want and print my list. Handy dandy little tool and I'm too too happy I still have the installer for the free version.

edit to hype the old free version of filegrabber.

by Member 25348569

'-------------------------------
Const ADS_NAME_INITTYPE_GC = 3
Const ADS_NAME_TYPE_NT4 = 3
Const ADS_NAME_TYPE_1779 = 1

sGroup = InputBox("Enter group name")
sGroup= "YourDomain\" & sGroup

Set objTrans = CreateObject("NameTranslate")
objTrans.Set ADS_NAME_TYPE_NT4, sGroup
strGroupDN = objTrans.Get(ADS_NAME_TYPE_1779)

Set objGroup = GetObject ("LDAP://" & strGroupDN)
objGroup.GetInfo

arrMemberOf = objGroup.GetEx("member")

WScript.Echo "Members:"
For Each strMember in arrMemberOf
Set objUser = GetObject ("LDAP://" & strMember)
objUser.GetInfo
WScript.echo objUser.DisplayName
Next
'-------------------------------

Copy and paste the bits between the dashed lines into a file - Getmembers.vbs for instance - change the YourDomain to whatever your domain is called and run

cscript getmembers.vbs //nologo > Members.txt

from a command line, enter the group name in the input box and there you go.

Neil :)

by statykserver

That does get the information now how could the file be modified to output the list into a text editor instead of having to click "ok" after each member is shown.

Here is what I just found out that seems to do just that:

dsquery group -name (object name here) |dsget group -members |dsget user -display >memberlist.txt

That will output the member list to a text file!

Thanks, and if you can figure out how to do it in the vbs file that will be great!

by Member 25348569

The easy way is - as I said in my post - run it from a CMD box with the output piped into a file. Start the program with cscript.

[b]cscript getmembers.vbs //nologo > Members.txt[/b]

Or...

'-------------------------------
Const ADS_NAME_INITTYPE_GC = 3
Const ADS_NAME_TYPE_NT4 = 3
Const ADS_NAME_TYPE_1779 = 1

Const ForAppending = 8

strGroup = InputBox("Enter group name")
strGroup= "YourDomain\" & strGroup
strFile = InputBox("Enter output file")

Set objFSO = CreateObject("Scripting.FilesystemObject")
Set objFile = objFSO.OpenTextFile(strFile, ForAppending, True)

Set objTrans = CreateObject("NameTranslate")
objTrans.Set ADS_NAME_TYPE_NT4, strGroup
strGroupDN = objTrans.Get(ADS_NAME_TYPE_1779)

Set objGroup = GetObject ("LDAP://" & strGroupDN)
objGroup.GetInfo

arrMemberOf = objGroup.GetEx("member")

For Each strMember in arrMemberOf
Set objUser = GetObject ("LDAP://" & strMember)
objUser.GetInfo
objFile.writeline objUser.DisplayName
Next

objFile.close
Set objFile = Nothing
Set objFSO = nothing
'-------------------------------

by bcardell1

you have to follow the instructions exact and the vbs file has to be in the same folder as the command prompt directory for example c:\users\username and you can't just right click the file to run it, you have to type the command "cscript getmembers.vbs //nologo > Members.txt" (without quotes) into the command prompt window and your members.txt file appears, I promise.

This discussion is closed to new replies.