If you haven't done this already you need to install the necessary modules:

Install-Module MSOnline

This is the snippet of code I usually run to quickly connect to O365.

function Connect-O365 {

$UserCredential = Get-Credential -UserName "username@domain.eu" -Message "Username has to be in the format of username@domain.eu"

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "https://ps.outlook.com/powershell/" -Credential 

$UserCredential -Authentication Basic -AllowRedirection

Import-PSSession $Session
Connect-MsolService -Credential $UserCredential

}

With this i can simply type Connect-O365 and automatically run the function (which i have automatically loaded in my PowerShell user profile).