Thursday, 18 August 2016

Export Office 365 Email Addresses to CSV using Powershell

In this post, I am going write steps to export the list of exchange online users and their email addresses from Office 365 to csv file. We can use the powershell cmdlet Get-Mailbox to get mailbox information and use the cmdlet Export-CSV to export content to csv file.

Note: Before proceed, Connect Exchange Online Remote PowerShell.

Then run the below powershell command to list the mailbox users and its primary email address.
Get-Mailbox -ResultSize Unlimited |Select-Object DisplayName,PrimarySmtpAddress
The following command export all the exchange online users and its associated email addresses to csv file.
Get-Mailbox -ResultSize Unlimited |
Select-Object DisplayName,PrimarySmtpAddress, @{n="EmailAddresses";e={$_.EmailAddresses |
Where-Object {$_ -like "smtp*"} | ForEach-Object {$_.Substring(5)}}} | 
Export-Csv "C:\\o365-email-addresses.csv" -NoTypeInformation -Encoding UTF8


1 comment:

  1. This is such a great resource that you are providing and you give it away for free. I love seeing blog that understand the value of providing a quality resource for free. find contact details