Exchange 2007 – Get Email Addresses for each Mailbox using Exchange Management Shell (EMS)

Your ads will be inserted here by

Easy Plugin for AdSense.

Please go to the plugin admin page to
Paste your ad code OR
Suppress this ad slot.

Ever needed to export the list of mailbox of your Microsoft Exchange 2007 with all alias and all the smtp addresses? Try this with this command:

Get-Mailbox | select name , alias ,EmailAddresses | foreach {
"Name: "+$_.name
"Alias: "+$_.alias
 
$_.EmailAddresses | foreach {
if($_.SmtpAddress){
if($_.IsPrimaryAddress){
"Primary SmtpAddress: $($_.SmtpAddress)"
} else {
"SmtpAddress: $($_.SmtpAddress)"
}
}
}
 
write-output ""
} > c:\smtp.txt

or use the out-file cmdlet..

######### Using Out-File Cmdlet ############
 
Get-Mailbox | select name , alias ,EmailAddresses | foreach {
"Name: "+$_.name
"Alias: "+$_.alias
 
$_.EmailAddresses | foreach {
if($_.SmtpAddress){
if($_.IsPrimaryAddress){
"Primary SmtpAddress: $($_.SmtpAddress)"
} else {
"SmtpAddress: $($_.SmtpAddress)"
}
}
}
write-output ""
} | out-file -filepath c:\smtp.txt -encoding ASCII

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.