How to Connect / Disconnect to Office 365 with Powershell
Connect to Office 365 with Powershell
- First make sure you have the remote signed execution policy set to true. You can do this by running PowerShell in admin mode and running: Set-ExecutionPolicy RemoteSigned
- Next, run the following to authenticate your self and import PowerShell commands to your local session:
$LiveCred = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange-ConnectionUri https://ps.outlook.com/powershell/ -Credential $LiveCred -Authentication Basic -AllowRedirection
Import-PSSession $Session
Disconnect from Office 365 with power script
Remove-PSSession $Session