The Exchange Online component of Office365 exposes a variant of the Exchange Management Shell that you’d normally use if you were managing an on-premises Exchange 2010 organization. Connecting to it requires a few steps which are documented here. I’ve been pasting in the three commands one at a time now for months and it’s gotten rather annoying. A bit of research reveals that you can add custom PowerShell code that is available anytime you launch a shell by modifying your PowerShell profile. You can read more about the various profiles you can modify here, but, I decided to simply modify the one specific to my user account. To do this, open a new PowerShell window and run this command:

notepad $PROFILE

If you haven’t done this before, notepad will prompt you to create a new file. Plug this code in the resultant file:

function Connect-ExchangeOnline
{
  $LiveCred = Get-Credential
  $global:Session365 = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $LiveCred -Authentication Basic -AllowRedirection
  
  Import-PSSession $global:Session365
}

function Disconnect-ExchangeOnline
{
  Remove-PSSession $global:Session365
}

Save and restart PowerShell, and you’ll be able to run Connect-ExchangeOnline to connect to Exchange Online in one easy step.