The very first thing you will do is to create a Windows PowerShell session to the remote location. For this, you need to figure out the “ConnectionURI” parameter. Once identified use this connection URI along with your credential (Which can be stored in XML) to create the PS session into the variable which later can be imported.
$session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell -Credential (Import-Clixml C:\MyCred.xml) -Authentication basic -AllowRedirection
Now you can import this session as below:
$credential = Get-Credential
Type in the username and password. Create a session using this variable:
$session = New-CsOnlineSession -Credential $credential
This will connect to the online services.