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
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!
5 Comments
What about Exchange 2013 (or 2016)? They don’t seem to expose the SmtpAddress field/attribute….
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.
Have you tried invoking the module before you remotely execute the command?
Is there a way to display the recipienttype with the results. (usermailbox, sharemailbox, mail contact, distribution groups, etc)
thanks
Great article!
Here is another alternative to obtain the list of primary and secondary SMTP addresses of the mailboxes:
https://www.sysadmit.com/2018/04/exchange-exportar-direcciones-smtp.html