office365: remotely connect to exchange online via powershell
run this first if you haven’t already:
Set-ExecutionPolicy RemoteSigned
you’ll probably want to switch back to Set-ExecutionPolicy Unrestricted once done
then:
$UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
Import-PSSession $Session
at this point run desired PS cmdlets like so:
Get-MailboxStatistics -Identity [UPN]
to end the session:
Remove-PSSession $Session
source:
https://technet.microsoft.com/en-us/library/jj984289%28v=exchg.150%29.aspx