Exchange PowerShell: List all SMTP email addresses in Exchange

4

Hello All,

As you all must be aware that I was writing a few articles on cleaning up activities for the domain, in my previous posts like Finding Empty groups and Expired accounts in Active Directory.

Today we will continue and see how to list all SMTP email addresses in Exchange associated with each account.

Although Email Addresses are most often associated with mailboxes, but not always because you might also have Distribution groups as well in your Exchange environment. Hence we will not be using Get-Mailbox cmdlet, but instead use Get-Recipient.

Now the best way to know the properties associated with each cmdlet, as you all might know is to pipe the cmdlet to Get-Member.

Let us run this and see what we have at our disposal.

Get-Recipient | Get-Member

Exchange PowerShell: List all SMTP email addresses in Exchange

You can see that we have a property called Email Addresses which is what we are interested in.

As I mentioned earlier we will using Get-Recipient instead of Get-Mailbox, let us see the actual reason behind this. We will be using the Measure-Object cmdlet to see the difference between the values.

I am using Get-Mailbox and piping it to Measure-Object and sorting it with the property Name

Exchange PowerShell: List all SMTP email addresses in Exchange

So in my demo environment, I only have one Distribution Group, hence the number is increased by one.

Moving on, lets use this below to select only the properties that we are interested in. Also we will be using the ExpandProperty along with select to get the associated properties with EmailAddresses.

Get-Recipient | Select Name -Expandproperty EmailAddresses

Exchange PowerShell: List all SMTP email addresses in Exchange

Now you see that we have SmtpAddress property available to us. So final command that we will be using is

Get-Recipient | Select Name -Expandproperty EmailAddresses | Select Name, SmtpAddress

Exchange PowerShell: List all SMTP email addresses in Exchange

Now if you want this to present this this to someone, simply output this to a csv file and impress everyone.

Get-Recipient | Select Name -Expandproperty EmailAddresses | Select Name, SmtpAddress | Export-Csv C:\SMTP.csv

This method works with both Exchange Server 2007 and 2010.

That’s it for today. I hope this was informative and thank you for reading!

Share.

About Author

I am Adil Arif, working as a Technical Support Engineer at VMware as well as an independent blogger and founder of Enterprise Daddy. In my current role, I am supporting infrastructure related to Windows and VMware datacenters.

4 Comments

  1. Hi,
    using “Get-Recipient | Select Name -Expandproperty EmailAddresses” doesn’t work when you use implicit remoting. IT only works directly on the exchange machine and probable on a client with the exchange administration tools installed.

  2. Is there a way to display the recipienttype with the results. (usermailbox, sharemailbox, mail contact, distribution groups, etc)

    thanks

Leave A Reply

LIKE WHAT YOU'VE READ?
If so, please join the community.  I’d love to send you exclusive content right to your email, and I’ll send you a free copy of my book, VMware vSphere 6.0 Lab on Workstation too!
Enter your name and email below, and I’ll see you on the inside!

SUBSCRIBE