Connect to office 365 with PowerShell

Use the following powershell command to connect to exchange online or Office 365

$cred = Get-Credential
$eolsession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid -Credential $cred -Authentication Basic -AllowRedirection
Import-PSSession $eolsession