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
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
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
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
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!