≡ Menu

Connect to Office365 with PowerShell (Exchange Online)

We were recently transitioned to Office365 and learned that certain settings and permissions did come across during the upgrade. This meant that some settings and permissions needed to be reconfigured via PowerShell. Back in the days of BPOS, you needed the Migration ToolKit installed in order to use any of the Microsoft Online related PowerShell Cmd-Lets. With Office365, you don’t need this! Instead, you need to open a server side connection to the cloud servers from your local machine. Below are the steps to do this.

  1. Load your Office365 credentials in a variable
    $Cred = Get-Credential
  2. Create a session variable which will configure a connection to the cloud servers
    $Sess = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $Cred -Authentication Basic -AllowRedirection
  3. Initialize the session
    Import-PSSession $Sess
  4. Run any of the Exchange Online Cmdlets found in the documentation.
  5. Once you’re done running commands, you can close the session
    Remove-PSSession $Sess

Note: The guts of this post came from a Microsoft Article which I never was able to come across in my searching, but rather was pointed to via a service request.

Comments on this entry are closed.