write-host "Getting credentials for connection to Exchange Online..." $UserCredential = Get-Credential write-host "Building session..." $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection write-host "Importing session and cmdlets..." Import-PSSession $Session write-host write-host "Remember to close the session when complete using Remove-PSSession!"