Connect to Office 365 with Powershell

#en, #office365 edit this page

In this Post I explain how to connect to Office 365 with Powershell and manage Exchange and Lync.

1. Install Microsoft Online Services Sign-In Assistant for IT Professionals BETA

2. Install the Office 365 cmdlets

3. Set Execution Policy to Remote Signed
Set-ExecutionPolicy RemoteSigned

Exchange Online

4. Connect to Exchange Online

Import-Module MSOnline
$ExchangeOnlineCred = Get-Credential
$ExchangeOnlineSession = New-PSSession –ConfigurationName Microsoft.Exchange -ConnectionUri -Credential $ExchangeOnlineCred -Authentication Basic -AllowRedirection
Import-PSSession $ExchangeOnlineSession -AllowClobber
Connect-MsolService –Credential $ExchangeOnlineCred

Now you are connected to Exchange Online:


Lync Online

4. Install Windows PowerShell Module for Lync Online

5. Connect to Lync Online

Import-module lynconlineconnector
$LyncOnlineCred = Get-Credential
$LyncOnlineSession = New-CsOnlineSession -Credential $LyncOnlineCred
Import-PSSession $LyncOnlineSession