Exchange Online PowerShell allows you to manage your Exchange Online settings from the command line. You use Windows PowerShell on your local computer to create a remote PowerShell session to Exchange Online. It’s a simple three-step process where you enter your Office 365 credentials, provide the required connection settings, and then import the Exchange Online cmdlets into your local Windows PowerShell session so that you can use them.
What do you need to know before you begin?
-
Estimated time to complete: 5 minutes
-
You can use the following versions of Windows:
-
Windows 10
-
Windows 8.1
-
Windows Server 2019
-
Windows Server 2016
-
Windows Server 2012 or Windows Server 2012 R2
-
Windows 7 Service Pack 1 (SP1)*
-
Windows Server 2008 R2 SP1*
* For older versions of Windows, you need to install the Microsoft.NET Framework 4.5 or later and then an updated version of the Windows Management Framework: 3.0, 4.0, or 5.1 (only one).
-
-
Windows PowerShell needs to be configured to run scripts, and by default, it isn’t. You’ll get the following error when you try to connect:
Files cannot be loaded because running scripts is disabled on this system. Provide a valid certificate with which to sign the files.
To require all PowerShell scripts that you download from the internet are signed by a trusted publisher, run the following command in an elevated Windows PowerShell window (a Windows PowerShell window you open by selecting Run as administrator):
Set-ExecutionPolicy RemoteSigned
You need to configure this setting only once on your computer, not every time you connect.
Connect to Exchange Online
- On your local computer, open Windows PowerShell and run the following command.
$UserCredential = Get-Credential
In the Windows PowerShell Credential Request dialog box, type your work or school account and password, and then click OK.
- Run the following command:
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
- Run the following command:
Import-PSSession $Session -DisableNameChecking
When you have finished be sure to disconnect your session using the following command:
Remove-PSSession $Session