Here follows some EMS code to list all SMTP addresses in Exchange 2007… really rather useful!!
Get-Mailbox -ResultSize “Unlimited” | select name, EmailAddresses | foreach {
“Name: “+$_.name
$_.EmailAddresses | foreach {
if($_.SmtpAddress){
if($_.IsPrimaryAddress){
“Primary SmtpAddress: $($_.SmtpAddress)”
} else {
“SmtpAddress: $($_.SmtpAddress)”
}
}
}
write-output “”
} > c:\Addresses.txt
And if you only want mailbox info for users in a specific OU then add
-OrganizationalUnit “Distinguished Name of OU”
To the command, so…
Get-Mailbox -ResultSize “Unlimited” -OrganizationalUnit “OU=OUNAME,DC=MyDomain,DC=Com” | select name, EmailAddresses | foreach {
“Name: “+$_.name
$_.EmailAddresses | foreach {
if($_.SmtpAddress){
if($_.IsPrimaryAddress){
“Primary SmtpAddress: $($_.SmtpAddress)”
} else {
“SmtpAddress: $($_.SmtpAddress)”
}
}
}
write-output “”
} > c:\Addresses.txt
Hope you find this useful!
N3ilb