You may use the script below in the Exchange Management Shell to list the primary email address of each mailbox in Microsoft Exchange Server 2007.

<#
.SYNOPSIS
This script will provide a list of all Microsoft Exchange users and their primary email address then provide the results in a text file.
.DESCRIPTION
This script will automate the process of providing a list of all Microsoft Exchange users and their primary email address then provide the results in a text file.
.EXAMPLE
N/A.
.AUTHOR
Written by Noel Enrique Alvarez on Thursday, March 24, 2016.
#>

#Request the name of the output file
$File = Read-Host “What would you like to name the file?”

#List all of the Microsoft Exchange users and their primary email address then provide the results in a text file
Get-Mailbox | Select Name, SamAccountName, PrimarySmtpAddress | format-list | Out-File -filepath “<<<INSERT PATH>>>\$File.txt”