Connect to Exchange Online Admin Using PowerShell - Untold.IT


Post Top Ad

Wednesday, February 6, 2019

Connect to Exchange Online Admin Using PowerShell

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.


  • Windows (7 SP1/8.1/10/Server 2008 R2 SP1/Server 2012 or 2012 R2/Server 2016)
  • Dot Net Framework 4.5 or Later
  • Updated version of the Windows Management Framework: 3.0, 4.0, or 5.1 (only one)


Step 1. 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):

You need to configure this setting only once on your computer, not every time you connect.

Step 2. Run the following Command and enter your Global administrator Account.

Note: If you have activated MFA on your account, use the APP PASSWORD generated to login using powershell.

Step 3. Run the command below to Create New PowerShell Session

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri -Credential $UserCredential -Authentication Basic -AllowRedirection

Step 4. Run the following command to create Remote Session

Import-PSSession $Session -DisableNameChecking

Step 5. Run the command below to Remove PowerShell Session

Remove-PSSession $Session

Note: Be sure to disconnect the remote PowerShell session when you're finished. If you close the Windows PowerShell window without disconnecting the session, you could use up all the remote PowerShell sessions available to you, and you'll need to wait for the sessions to expire. To disconnect the remote PowerShell session, run the following command.

No comments:

Post a Comment

Post Top Ad