As more and more businesses are moving to Office 365 for email, IM etc managing their respective service lines is a day to day task for an IT Engineer. Similar to managing your environment through the Office 365 portal, admins also use PowerShell for more flexibility every now and then. In order to perform any complex admin tasks on Exchange Online, admins need to connect to their O365 tenant. The below commands can help you achieve the same :
$UserCredential = Get-Credential
Click Enter Key after the above command. You will be asked to supply your O365 tenant credentials.
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
The modules will be loaded and you will be connected to Exchange Online.