List all SMTP Addresses for all Mailboxes or Distribution Groups in Exchange

This PowerShell script allows you to export from Exchange, a list of addresses and all associated alias'/SMTP Addresses. This works for both mailboxes and for distribution groups.

 

$Mailboxes = Get-Mailbox -ResultSize Unlimited
ForEach ($Mailbox In $Mailboxes) {
  $DisplayName = """" + $Mailbox.DisplayName + """"
  $EMailAddresses = $Mailbox.EMailAddresses
  $EMailString = """"
  ForEach ($EMailAddress In $EMailAddresses) {
    If ($EMailString -eq """") {
      $EMailString += $EMailAddress.ProxyAddressString
    } Else {
      $EMailString += "," + $EMailAddress.ProxyAddressString
    }
    $EMailString
  }
  $EMailString = $EMailString + """"
  $DisplayName + "," + $EMailString | Out-File -FilePath "Report.csv" -Append

Add comment