Find List Members

We are making a move from Reddfish Listserver (horrible - don't even Google it) to Mailman. Reddfish "integrated" with Exchange by working with AD groups and contact types. During this migration, I have to get the current lists into mailman which means I have to get a nice clean list of line seperated email addresses to feed into Mailman. Here is the code I use to get this to work. Very simple, but I hope it still proves useful.

  1. add-pssnapin -erroraction silentlycontinue Microsoft.Exchange.Management.Powershell.Admin
  2.  
  3. $listname = 'You List Name Here'
  4. $filename = "c:\\$listname.txt"
  5.  
  6. $listmembers = get-distributiongroupmember $listname
  7.  
  8. foreach ($member in $listmembers) {
  9. write-output $member.primarysmtpaddress.toString() >> "$filename"
  10. }