How to connect to Office 365 with PowerShell


Before connecting for the first time, enable Windows PowerShell to run signed scripts:

  • Set-ExecutionPolicy RemoteSigned

Every time you want to connect, run the following commands:

  • $UserCredential = Get-Credential (enter your Office 365 username & password)
  • $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri -Credential $UserCredential -Authentication Basic -AllowRedirection
  • Import-PSSession $Session

And don’t forget to close your session when you’re done:

  • Remove-PSSession $Session

[source: ]

Was this answer helpful ? Yes (0) / No (0)

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.