This can be done in 3 easy steps (taken from the article at https://docs.microsoft.com/en-us/powershell/exchange/exchange-online/connect-to-exchange-online-powershell/connect-to-exchange-online-powershell?view=exchange-ps)
$UserCredential = Get-Credential
When prompted, enter your tenant logon (username@<tenant>.onmicrosoft.com) information including password
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
This creates a session object holding the connection to Exchange Online.
Import-PSSession $Session -DisableNameChecking
This imports the session (places it live) inside your current Powershell session. You could, of course, also do a
Enter-PSSession $Session
if you want to connect and run the commands remotely / directly on Exchange Online but then you lose all sorts of things like auto-complete.