![]() |
![]() |
|
|||||||
| Register | Forum Rules | Getting Started! - Guide | Blog | Videos | Gallery | Members List | Social Groups | Mark Forums Read |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Guest
Posts: n/a
|
Export users in a security/distribution list to txt file?
Hi,
How can I export users a list of the users in an AD security group or distribution list to a txt file? |
|
|
|
#2 |
|
Guest
Posts: n/a
|
RE: Export users in a security/distribution list to txt file?
Hi Cyborg,
This is a Vbscript from scripting guys: http://www.microsoft.com/technet/scr...4/hey1122.mspx Or, you can use this: dsquery group -name XXX > groups.txt for /f "tokens=*" %%g in (groups.txt) do @echo %%g >>membership.txt && echo Members: >>membership.txt && dsget group %%g -members -expand >>membership.txt && echo ********************* >>membership.txt Have a nice day! "Cyborg" wrote: > Hi, > > How can I export users a list of the users in an AD security group or > distribution list to a txt file? > > |
|
|
|
#3 |
|
Guest
Posts: n/a
|
Re: Export users in a security/distribution list to txt file?
"Cyborg" <apollo13@btinternet.com> wrote in message news FEDCA5D-363E-4225-9A8E-E536EE6CD589@microsoft.com...> Hi, > > How can I export users a list of the users in an AD security group or > distribution list to a txt file? One way at a command prompt: net group <groupname> > report.txt Another way using csvde at a command prompt: csvde -f report.txt -r (sAMAccountName=<groupname>) -l member Finally, you can use VBScript if you have the Distinguished Name of the group: ====== Set objGroup = GetObject("LDAP://cn=TestGroup,ou=West,dc=MyDomain,dc=com") For Each objMember in objGroup.Members Wscript.Echo objMember.Name Next ===== You can run this at a command prompt with the cscript host and redirect the output to a text file. For example, if the program is saved in the file ListGroup.vbs, the following command will create report.txt with the group members: cscript //nologo ListGroup.vbs > report.txt With the VBScript program, you can format the resulting file any way you like: I think you can also use other utilities. -- Richard Mueller MVP Directory Services Hilltop Lab - http://www.rlmueller.net -- |
|
|
|
#4 |
|
Guest
Posts: n/a
|
Re: Export users in a security/distribution list to txt file?
How do I run the script?
Many thanks "Richard Mueller [MVP]" <rlmueller-nospam@ameritech.nospam.net> wrote in message news:O8EVJNxxIHA.4772@TK2MSFTNGP03.phx.gbl... > > "Cyborg" <apollo13@btinternet.com> wrote in message > news FEDCA5D-363E-4225-9A8E-E536EE6CD589@microsoft.com...>> Hi, >> >> How can I export users a list of the users in an AD security group or >> distribution list to a txt file? > > One way at a command prompt: > > net group <groupname> > report.txt > > Another way using csvde at a command prompt: > > csvde -f report.txt -r (sAMAccountName=<groupname>) -l member > > Finally, you can use VBScript if you have the Distinguished Name of the > group: > ====== > Set objGroup = GetObject("LDAP://cn=TestGroup,ou=West,dc=MyDomain,dc=com") > For Each objMember in objGroup.Members > Wscript.Echo objMember.Name > Next > ===== > You can run this at a command prompt with the cscript host and redirect > the output to a text file. For example, if the program is saved in the > file ListGroup.vbs, the following command will create report.txt with the > group members: > > cscript //nologo ListGroup.vbs > report.txt > > With the VBScript program, you can format the resulting file any way you > like: I think you can also use other utilities. > > -- > Richard Mueller > MVP Directory Services > Hilltop Lab - http://www.rlmueller.net > -- > > |
|
|
|
#5 |
|
Guest
Posts: n/a
|
Re: Export users in a security/distribution list to txt file?
Save the VBScript program in a text file with a *.vbs extension, for example
Members.vbs. You can use notepad to create the file. Be sure you code the Distinguished Name of your group in the program. Save the file where you can easily find it. Then go to a Command Prompt. On most clients you can click "Start", "Run...", then enter "Cmd" and click "OK". At the command prompt navigate to the folder where the file Members.vbs is saved. Then enter the following to command to create the file "report.txt" in the same folder: cscript //nologo Members.vbs > report.txt I sometimes go to the Command Prompt first and use the Edit command. For example, I would enter "edit Example.vbs". If the file exists it is opened and I can edit it. Otherwise the file is created and I type in my program, exit, save, and run it with cscript. You can use the edit command to modify the file and change the group, for example, or have the program output "cn" (the Common Name) or "distinguishedName" instead of Name. Or, you might want the program to output the "pre-Windows 2000 logon name", which is the value of the "sAMAccountName" attribute. For example, the program would then be: =========== Set objGroup = GetObject("LDAP://cn=TestGroup,ou=West,dc=MyDomain,dc=com") For Each objMember in objGroup.Members Wscript.Echo objMember.sAMAccountName Next =========== The tricky part usually is getting the Distinguished Name of the group. You need to take account of where in the hierarchy of AD the group object resides. In my example the group TestGroup is in the OU called "West", which is in the root of the domain MyDomain.com. -- Richard Mueller MVP Directory Services Hilltop Lab - http://www.rlmueller.net -- "Cyborg" <apollo13@btinternet.com> wrote in message news:97A8DB52-1311-445D-9402-2268C12517AC@microsoft.com... > How do I run the script? > > Many thanks > > > "Richard Mueller [MVP]" <rlmueller-nospam@ameritech.nospam.net> wrote in > message news:O8EVJNxxIHA.4772@TK2MSFTNGP03.phx.gbl... >> >> "Cyborg" <apollo13@btinternet.com> wrote in message >> news FEDCA5D-363E-4225-9A8E-E536EE6CD589@microsoft.com...>>> Hi, >>> >>> How can I export users a list of the users in an AD security group or >>> distribution list to a txt file? >> >> One way at a command prompt: >> >> net group <groupname> > report.txt >> >> Another way using csvde at a command prompt: >> >> csvde -f report.txt -r (sAMAccountName=<groupname>) -l member >> >> Finally, you can use VBScript if you have the Distinguished Name of the >> group: >> ====== >> Set objGroup = >> GetObject("LDAP://cn=TestGroup,ou=West,dc=MyDomain,dc=com") >> For Each objMember in objGroup.Members >> Wscript.Echo objMember.Name >> Next >> ===== >> You can run this at a command prompt with the cscript host and redirect >> the output to a text file. For example, if the program is saved in the >> file ListGroup.vbs, the following command will create report.txt with the >> group members: >> >> cscript //nologo ListGroup.vbs > report.txt >> >> With the VBScript program, you can format the resulting file any way you >> like: I think you can also use other utilities. >> >> -- >> Richard Mueller >> MVP Directory Services >> Hilltop Lab - http://www.rlmueller.net >> -- >> >> > |
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
< Home - Windows Help - MS Office Help - Hardware Support >
| New To Site? | Need Help? |