Logging into Office 365 with Powershell

Make sure you have all the modules:

Install-Module -Name MSOnline
Install-Module -Name AzureAD 

Then Login

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

#Add compliance center
$objSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.compliance.protection.outlook.com/powershell-liveid/ -Credential $objCred -Authentication Basic –AllowRedirection
Import-PSSession $objSession