How to connect in PowerShell on Office 365

13 November 2019 Off By Rached CHADER

PowerShell Office 365 allows you to manage your Office 365 settings from the command line.
You must :

  • Use PowerShell version 5.1 or later.
  • Use a 64-bit version of Windows. Support for the 32-bit version of the Microsoft Azure Active Directory Module for Windows PowerShell ceased in October 2014.

Here’s how you can connect:
Open PowerShell is used the following script, for my part I prefer to use PowerShell ISE.

1
2
3
4
5
6
7
8
9
10
11
Import-Module MSOnline

Connect-MsolService -Credential $Credential

$msoExchangeURL = “https://ps.outlook.com/powershell/

$session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri

$msoExchangeURL -Credential $Credential -Authentication Basic -AllowRedirection

Import-PSSession $session

Do not forget to log out via the following command at the end of the intervention:

1
Remove-PSSession $Session

Visits: 283