MS Office 365

How-to: Connect to Exchange Online PowerShell | Step-by-Step

Let’s get started To Connect to Exchange Online PowerShell

Prerequisites for the Exchange Online PowerShell module

There are two main sets of prerequisites for using the Exchange Online PowerShell module:

Software and System:

  • PowerShell version:
    • Windows PowerShell 5.1 or higher(on Windows)
    • PowerShell 7 or higher (Linux, or macOS)

To check your current power-shell installed in system try any of below methods

  • Microsoft .NET Framework: Version 4.7.2 or later (required for module versions 2.0.5 and later)

Permissions and Access:

  • Office 365 account: You need an Office 365 account with Exchange Online licenses assigned to it.
  • Administrative role: You need the Global administrator or Exchange administrator role in your Office 365 tenant to connect and manage your Exchange Online environment.

Additional notes:

  • Remote PowerShell connections are deprecated: Microsoft recommends using REST-based connections instead.
  • REST-based connections require additional modules: PowerShellGet and PackageManagement modules are needed for REST connections.
  • Module version considerations: Different versions of the module might have additional requirements. Check the official documentation for your specific version.
  • Set the PowerShell execution policy to RemoteSigned:
    We can’t install PowerShell scripts by default – this is the default behavior of PowerShell. Therefore, we need to set the execution policy that will allow us to subsequently install Exchange Online PowerShell
    Open PowerShell on your computer, and let’s sign the execution policy, which, in theory, protects you from scripts that you don’t trust. For more information about execution policies, see About Execution Policies.
  • Use SSL 3.0 and TLS 1.2 or TLS 1.3 to establish secure HTTPS connections to Microsoft repository

Step 1: Install Exchange Online PowerShell module

  • We can check If module is already installed, by using the following command :
  • Or for the just current user account:
  • Verify Installation: To verify the module is installed and loaded, run the command again

More info About the Exchange Online PowerShell module

Step 2: Update Exchange Online PowerShell Module

  • Now we can update it by running this command
  • To confirm that the update was successful, run the following commands to check the version information of the module to Compare with the latest version that’s installed

Step 3: Connect with an interactive login prompt

Now, if we try to execute the module load or connect command without executing the ‘Set-ExecutionPolicy RemoteSigned‘ command mentioned in the prerequisites, we will face a failure above

But If we have already executed it, the module will be loaded and connected successfully

Step 4: Disconnect when you’re finished

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

To silently disconnect without a confirmation prompt, run the following command:

Helpful Resources:

Thanks for reading and follow us

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button
TOC ......