Below the code used to connect to Office 365 with Powershell.

#Ask for O365 Credentials $Credentials = Get-Credential 

#Build session to O365 with specified credentials 
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $Credentials -Authentication Basic -AllowRedirection Import-PSSession $Session