See below to export all E-Mail addresses from Office 365 Exchange Online. If you have never connected to Powershell before then you need to download the Office 365 Powershell Cmdlets from Microsoft.
Connecting to Powershell is easy: Installing Windows PowerShell cmdlets only sets the stage.
This does nothing for actually connecting them to the Microsoft Office 365 cloud. Connecting to the cloud requires a cumbersome—but straightforward—five-step process:
1. Import your newly installed Online Services module
2. Enter Office 365 credentials
3. Create a remote session
4. Import that session’s commands into your local Windows PowerShell session
5. Connect to Office 365 services After installing the Cmdlets, open up Powershell and type the following:
$session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "https://ps.outlook.com/powershell/" -Credential $cred -Authentication Basic -AllowRedirection
This will prompt for a login username and password; use your administrator login for Office 365. You next need to import the session:
This should connect you to Powershell. If you cannot execute commands you need to set the execution policy to Remote-Signed, as below:
After this is done you’ll be able to run your command to export data. Running the following snippet will export ALL email addresses in your organization to a CSV file called addresses.csv.
Get-Recipient -ResultSize Unlimited | select DisplayName,RecipientType,EmailAddresses | Export-Csv addresses.csv