How to connect to Office 365 with PowerShell

0 Comments

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 https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
  • Import-PSSession $Session

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

  • Remove-PSSession $Session

[source: https://technet.microsoft.com/en-us/library/jj984289(v=exchg.160).aspx ]

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

Leave a Reply

Your email address will not be published. Required fields are marked *

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

reduction