To connect Powershell to Office365 (with MSOnline module and ExhangeOnline modules loaded - run on an on-prem Exchange server for full benefits)
((Powershell 5.1 or better needed!)
Set-ExecutionPolicy Unrestricted
$UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
Import-PSSession $Session
Import-Module MSOnline
Connect-MsolService