Link to home
Start Free TrialLog in
Avatar of Tacobell2000
Tacobell2000Flag for Canada

asked on

how to export members of a global security group into excel

Hello,

I have to create a long and tedious email distribution list which contains about 40 global security groups. There is a group that has all the groups that i need, i just have to create a global Distribution group and name it the same but add DL at the end of the name.
Is there a way to highlight all the groups and paste them into an excel document. Copy the excel spreadsheet and paste it into the newly created distribution list?
For some reason when i from the command prompt type:

net group "Group Name" /domain the result is:

Members

-------------------------------------------------------------------------------
The command completed successfully.


tacobell2000
Avatar of drmweaver
drmweaver

Try using this as I find ADSI to do whatever I need when it comes to AD.

http://msdn.microsoft.com/en-us/library/aa772170.aspx
Paste the script below into a text file with a .cmd extension.  Customize the value of the oldgroup variable with the SAM name of the security group.  Running the script will create a global distribution group with the same members as the security group.

This uses dsquery, dsadd, dsget, and dsmod, so either run it on a 2003 server or on a workstation with the 2003 Admin Pack installed.
http://www.microsoft.com/downloads/details.aspx?FamilyID=c16ae515-c8f4-47ef-a1e4-a8dcbacff8e3

@echo off
setlocal
 
set oldgroup=yourgroup
 
for /F "tokens=2* delims=," %%G in ('dsquery group -samid %oldgroup%') do (
 set oldgroupdn="CN=%oldgroup%,%%G,%%H
 set newgroupdn="CN=%oldgroup%DL,%%G,%%H
)
 
dsadd group %newgroupdn% -secgrp no -scope g
dsget group %oldgroupdn% -members | dsmod group %newgroupdn% -addmbr

Open in new window

Avatar of Tacobell2000

ASKER

Not too sure if i did this correctly. Please take a look at the code below. I saved it with a cmd extension and double clicked in a lab environment on a domain controller and the command window appears and it stays jammed.
@echo off
setlocal
 
set it_test=it_test_DL
 
for /F "tokens=2* delims=," %%G in ('dsquery group -samid %it_test%') do (
 set it_testdn="CN=%it_test%,%%G,%%H
 set newgroupdn="CN=%it_test%DL,%%G,%%H
)
 
dsadd group %newgroupdn% -secgrp no -scope g
dsget group %it_testdn% -members | dsmod group %newgroupdn% -addmbr

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Shift-3
Shift-3
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
that did it!

thank you very much!!

Tacobell2000