How to Connect Exchange Online PowerShell: A Quick and Easy Tutorial

how to connect Exchange Online PowerShell
Admin ~ Modified: May 17th, 2024 ~ Microsoft Exchange Server ~ 7 Minutes Reading

Summary:- Are you struggling with how to connect Exchange Online PowerShell? It can be a hectic task, especially for beginners. Don’t worry this blog will provide you with complete knowledge about how to install the Exchange Online PowerShell module. With this essential tool, you can easily manage your Exchange Online environment and increase the productivity of the organization. 

Table of Contents,

Nowadays where cloud-based services like Microsoft 365 are common and increasing rapidly. Therefore, knowing how to connect Exchange Online PowerShell is essential for managing emails and communication within your organization. Additionally, PowerShell allows you to automate the tasks that are difficult to operate with the Exchange Admin Center. 

PowerShell: An Overview

PowerShell is the tool used by the administration for managing cloud services including Exchange Online in the Microsoft 365 suite. By using this the life of the admin becomes easier. There are different cmdlets present in the Exchange Online module including create/manage/retrieve objects, and configure settings.

Moreover, to manage your Exchange Online environment from the command line you need to install the Exchange Online PowerShell module. Exchange Online PowerShell is used to establish new mailboxes, adjust mailbox permissions, or perform other administrative tasks.

Read More: Exchange On-Premise vs Exchange Online

Prerequisites to Install the Exchange Online PowerShell Module 

If you want to connect with Exchange Online PowerShell you need to fulfill the necessary prerequisites. It includes an active Office 365 subscription, Windows PowerShell 5.1 or later installed on your computer, and the Exchange Online Remote PowerShell Module.

Some more prerequisites are as follows.

System requirement – It is important to check whether your system meets the requirement to install the Exchange Online PowerShell module or not. Here, the table below represents about the same.

Requirement Details
Operating System Windows 7 or later
.NET Framework .NET Framework 4.7.2 or later
Windows PowerShell Windows PowerShell 5.1 or later
Memory At least 4 GB RAM
Hard Disk Space At least 1 GB of free disk space

 

Installation of the necessary software – You need to follow the following steps to install the necessary software used to connect to Exchange Online PowerShell.

Step 1. Open the Windows PowerShell as an administrator in your system.
Step 2. You need to Run the following command to  Install Microsoft Online services.

Install-Module MSOnline

Step 3.  To install the Azure Active Directory PowerShell for the Graph module run this command

Install-Module AzureAD

Step 4. Run this command to install the Exchange Online PowerShell module:

Install-Module ExchangeOnlineManagement

Step 5. After installation of the module, you can import it using the following command:

Import-Module ExchangeOnlineManagement

These are the steps necessary for the installation of the  Exchange Online PowerShell module and to start managing their Exchange Online environment.

Note: NuGet provider is required to continue where you need to Press Y for yes and N for No.

Read More: How To Create A Security Group In The Exchange Admin Center

Setting Up The Environment 

Configuring execution policies – If you are planning to connect to Exchange Online PowerShell, first, the user needs to configure the execution policy on their computer. You need to open the PowerShell as administrator and run this command.

Set-ExecutionPolicy RemoteSigned.

This command helps in the execution of local scripts and scripts that a trusted publisher signs.

Verify Connectivity – After completing the execution, the user needs to verify the connectivity to Exchange Online PowerShell by running the command:

Verify Connectivity

The above command is used to initiate the user for Microsoft 365 credentials and helps to create a new PowerShell session to Exchange Online. Moreover, the Import-PSSession cmdlet imports the Exchange Online cmdlets into the local PowerShell session. If there is any error, the user needs to check internet connectivity and permission settings.

Install the Exchange Online PowerShell Module 

To connect with Exchange Online PowerShell, you need to install the Exchange Online PowerShell module. It contains the command palette used to manage Exchange Online using PowerShell.

If you want to  Install the Exchange Online PowerShell module you need to follow the steps given below.

Step 1. First, Open the Windows PowerShell with the administrator rights.
Step 2. Run the command mentioned below to install the Exchange Online PowerShell module.

 Install-Module ExchangeOnlineManagement

Step 3. If prompted to install type Y (for Yes) and press the Enter button.

How to Connect Exchange Online PowerShell

This section will explain to you how to connect to Exchange Online using PowerShell. 

There are two ways to connect with Exchange Online.

  • With Multi-Factors Authentication (MFA)
  • Without multi-factor authentication

Let’s look at the steps to set up them.

1. With Multi-Factors Authentication (MFA)

Step 1. After installation of the module, run this command to connect Exchange Online PowerShell.

Connect-ExchangeOnline -UserPrincipalName <UPN>

Step 2. Replace  <UPN> with the user principal name.
Step 3. When initiated, enter your MFA credentials in it.

2. Without Multi-Factor Authentication(MFA)

If the user wants to connect without multi-factor authentication, follow the command mentioned below.

After the module is installed, follow this command,

Without multi-factor authentication

When prompted, you need to enter your Exchange Online admin credentials.

By following the steps outlined above, you can quickly install and solve the query on how to connect Exchange Online PowerShell and start managing your Exchange Online environment.

Disconnect the Exchange Online PowerShell Session

If you are done with your PowerShell module work, You have to disconnect the session, rather than closing the PowerShell window. This way comes under good practices and saves the computation of the CPU also.

Follow this cmd to do so.

Disconnect-ExchangeOnline -Confirm:$False

How to Manage Exchange Online with PowerShell

You need to follow some of the commands listed in the table to manage Exchange Online with PowerShell after Installing the Exchange Online PowerShell module.

Read More: What is Exchange co-existence

Commands Description
Get-Mailbox Retrieves information about the mailboxes.
New-Mailbox Creates a new mailbox for a user.
Set-Mailbox Modifies the properties of an existing mailbox.
Get-DistributionGroup Retrieves information about distribution groups.
New-DistributionGroup Creates a new distribution group.
Set-DistributionGroup Modifies the properties of an existing distribution group.

Moreover, These commands can be used to perform different tasks, including creating & managing mailboxes, and distribution groups, and configuring permissions.

Want to migrate your mailbox data from ExchangeOnline to any other subscription? But don’t know how it is possible. One of the tools is the Migrator Wizard Exchange Migration Tool used to save the valuable time of the admin. Additionally,  saves from the risk factors that come during the migration process and reduces the chances of data loss too. Therefore Every second organization is using an automated tool for the same. You can download and purchase the tool from the buttons given below.

Download Now Purchase Now

Read More : Office 365 Staged Migration

Binding Up

In this article, we will discuss how to connect Exchange Online PowerShell after that, you need to  Install the Exchange Online PowerShell module. However, you must fulfill the prerequisites for the installation first. It helps to ease and manage emails and communication within your organization. With the steps mentioned, you can easily connect & use it. In addition, PowerShell is a powerful tool used to manage cloud services and other services on the administration level.