Powershell script and distro group members
Howdy, OK I'm at my wits end and I'm now willing to ask for help. I have a file with a list of distribution groups. I need my script to read that input file and, for each distro group, list the members of the group. This needs to be written to an output file with the group name followed by the members and then a hard return after each group. The groups are all in the same OU. Here's what I'm trying to get my output to look like: Group name1 member1 member2 Group name2 member1 member3 Thanks for any help!
June 14th, 2011 1:06am

This is a quick script i wrote once; the output is ugly, but I think it will meet your requirements. It still needs cleanup, but it should get what you need. The group names are in c:\hgroups5.txt, one group name per line. The output goes to c:\hgroups51.txt. This uses the Quest Active Roles Management Shell which you can download for free from http://www.quest.com/powershell/activeroles-server.aspx $Groups = get-content c:\hgroups5. foreach ($Group in $Groups) { add-content -path c:\hgroups51.txt "Group Name" get-qadgroup $group | select name | add-content c:\hgroups51.txt get-qadgroupmember $group | Select name | add-content c:\hgroups51.txt add-content -path c:\hgroups51.txt " " }TBrennan
Free Windows Admin Tool Kit Click here and download it now
June 14th, 2011 1:47am

thanks TP that got me on the right track at least. I added the ability to list nested group members and now I have a nice list.
June 14th, 2011 11:42pm

Hi, Try this: $groups=get-distributiongroup foreach($group in $groups){ "">>aaa.txt $group.name>>aaa.txt $members=get-distributiongroupmember -Identity $group.name foreach($member in $members){ $member.name>>aaa.txt } }Please remember to click Mark as Answer on the post that helps you, and to click Unmark as Answer if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
Free Windows Admin Tool Kit Click here and download it now
June 15th, 2011 9:11am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics