Problem:
How do I connect to Office 365/Exchange online and make changes or retrieve data using PowerShell?
Solution:
First you need to install the AzureAD PowerShell module:
Install-Module -Name AzureAD
Then you need to install the Exchange Online PowerShell module:
Install-Module -Name ExchangeOnlineManagement -RequiredVersion 2.0.5
Then you need to import the Exchange Online PowerShell module:
Import-Module ExchangeOnlineManagement
Then you need to connect to AzureAD:
Connect-AzureAD
Then you need to connect to Exchange Online:
Connect-ExchangeOnline -UserPrincipalName robin.clarke@mytenant.com
Now you can run some commands:
Get-Mailbox -ResultSize unlimited | export-csv "c:\temp\Mailbox.csv" -nti