How to Install Exchange Online PowerShell Module?

Requirement: Install Exchange Online PowerShell Module for Microsoft 365.

Introduction

Are you looking to streamline your administrative tasks and want to learn how to install the PowerShell module? Look no further! This blog post will guide you through step-by-step instructions on successfully installing the Exchange Online PowerShell Module. With our easy-to-follow guide, you’ll be up and running in no time, able to manage your organization’s email accounts more efficiently and quickly. Let’s dive in and get started!

Microsoft Exchange Online is a cloud-based email and calendaring solution, part of the Microsoft Office 365 suite of applications. Businesses of all sizes widely use it to manage their email communication. You can use a web-based Exchange Admin Center interface to manage Exchange Online. However, most prefer PowerShell as it automates tasks and efficiently manages your environment. Also, it provides more granular control over your Exchange Online environment, allowing you to perform tasks that are not available in the Exchange Online Admin Center.

Exchange Online PowerShell Module is a powerful command-line tool that allows administrators to manage the Exchange Online Environment. In this article, I will provide a step-by-step guide on how to connect to Exchange Online PowerShell. I will also discuss the prerequisites, common issues faced while connecting, and best practices to follow while using Exchange Online PowerShell.

To get started, you must first install the Exchange Online PowerShell module. The installation process is straightforward and requires very little setup. Once installed, you will need to connect to Exchange Online PowerShell. You will need to use your Office 365 administrator credentials to do this. After connecting, you can easily manage and configure various aspects of your Exchange Online environment.

Why Should we use the Exchange Online PowerShell Module?

Exchange Online PowerShell allows you to manage your Exchange Online environment more efficiently and effectively. With PowerShell, you can automate tasks, such as creating, modifying, Viewing data, and deleting Microsoft 365 Exchange Online objects, such as Mailboxes, distribution groups, users, contacts, and other objects, which can save you a lot of time and effort.

So, why should we install the Exchange Online PowerShell module? One of the significant benefits of using the Exchange Online PowerShell module is that it lets you automate repetitive tasks. For example, if you need to create a new user mailbox on Exchange Online, you can use a cmdlet instead of going through the manual process. Another benefit of using the Exchange Online PowerShell module is that it gives you more control over what actions are taken in your Exchange Online environment. For example, when you use the New-Mailbox cmdlet to create a new user mailbox, you can specify precisely what settings should be applied to the mailbox. This level of control can be helpful when troubleshooting issues or simply when trying to maintain a consistent environment.

If you need to manage your Exchange Online environment or want more control over the actions taken on your environment, then installing the module is a great idea. Unlike its previous version, The new Exchange Online PowerShell module V3, doesn’t need basic authentication and Winrm client/Win RM basic auth, as it supports certificate-based authentication.

Here are some of the key benefits of the Exchange Online PowerShell Module:

  • Automate repetitive tasks like user creation, mailbox migrations, etc.
  • Manage Exchange Online settings unavailable in the Office 365 admin center GUI.
  • Configure policies, permissions, and groups in bulk.
  • Integrate Exchange Online management into scripts and other tools.
  • Avoid throttling limits when managing a large number of objects.

Overall, the Exchange Online PowerShell module unlocks the full capabilities of Exchange Online programmatically for administrators.

Prerequisites for connecting to Exchange Online PowerShell

Before you install the Exchange Online PowerShell module, you need to ensure that you have the following prerequisites in place:

  • You must have an Office 365 account with Exchange Online licenses assigned to it.
  • You must have an Exchange Administrator role and credentials for the Office 365 tenant.
  • A computer running Windows 7 or later, Windows Server 2008 R2 or later with PowerShell 5.1 or later.
  • Microsoft .NET Framework 4.7.1 or later
  • On non-Windows operating systems like Linux or macOS – PowerShell 7 or later.

You can check the version of Windows PowerShell by running the following command in PowerShell:

$PSVersionTable.PSVersion

Install Exchange Online PowerShell module

To manage Exchange Online using PowerShell, you need to install the Exchange Online Management module. Let’s discuss how to install the Exchange Online PowerShell module on your computer. Installing the Exchange Online PowerShell module is a straightforward process. The module can be installed using the Install-Module cmdlet. It is crucial to Set Execution Policy in PowerShell using “Set-ExecutionPolicy RemoteSigned”, as the execution policy needs to be configured to run scripts, and by default, it isn’t!

You can check to see if the module is already installed by running the following command:

Get-InstalledModule -Name ExchangeOnlineManagement

If the module is installed, you should see it listed in the output. If it is not installed, you’ll see an error message, “No match was found for the specified search criteria and module names ‘ExchangeOnlineManagement’.”

You can install it by following the below steps:

  1. Open Windows PowerShell as an administrator (To do this, Type PowerShell in search >> right-click on the Windows PowerShell icon >> Select “Run as administrator”).
    run powershell as administrator
  2. Install the Exchange Online PowerShell module by running the following command:
Install-Module -Name ExchangeOnlineManagement
  • If prompted to install the NuGet provider, Press Y and Enter. This will Install the PowerShellGet module.
  • If prompted to install the module from an untrusted repository, type “Y” and press Enter.
How to Install Exchange Online PowerShell Module

Wait for the installation process to complete. This may take a few minutes, depending on your internet connection speed. The latest module (Exchange Online PowerShell v3 module – EXO V3 as of today – Which uses REST API and modern authentication and doesn’t rely on the remote PowerShell session!) will be downloaded from PSGallery and installed on your computer, and you can now connect to Exchange Online PowerShell. Use the “-Scope CurrentUser” parameter to install it for the current user account.

Install-Module -Name ExchangeOnlineManagement -Scope CurrentUser 

Importing the Exchange Online PowerShell module

You can import the Exchange Online PowerShell module using the Import-Module cmdlet. Here are the steps to import the module:

Import-Module ExchangeOnlineManagement

This will make all the cmdlets in the module available for use in PowerShell.

Connecting to Exchange Online PowerShell using Connect-ExchangeOnline cmdlet

After installation, you can connect to Exchange Online from Windows PowerShell. Start by running the following cmdlet in Windows PowerShell with administrative user rights. To connect to Exchange Online PowerShell, you can use the Connect-ExchangeOnline cmdlet. Here are the steps to connect:

  1. Open the PowerShell console (or any other PowerShell editors like Windows PowerShell ISE / Visual Studio Code).
  2. Run the following command:
Connect-ExchangeOnline -UserPrincipalName "Salaudeen@crescent.com" -ShowProgress $false

Replace the UPN “Salaudeen@Crescent.com” With the user principal name of your administrator account. You may receive a Sign-in window pop up after running the command, simply enter your password, and you will be connected to Exchange Online. If you have multi-factor authentication (MFA) enabled, enter your username, password, and you will be prompted to authenticate using your preferred method for verification code (such as text message or authenticator app). Use the “-ShowBanner:$False” switch to hide the announcement banner. In non-MFA enabled scenarios, You can get the credentials and connect to Exchange Online as:

#Get Credentials to connect
$credential = Get-Credential

#Connect to Exchange Online
Connect-ExchangeOnline -Credential $credential

You will now be connected to Exchange Online PowerShell, and you can begin managing your Exchange Online environment.

Commands Available in Exchange Online PowerShell Module

One of the advantages of using the Exchange Online PowerShell module is its rich cmdlets. Cmdlets are special scripts that allow you to perform various actions in the online email service, such as creating a new mailbox or moving emails to another account. The Exchange Online PowerShell module contains several cmdlets to manage your Exchange Online environment. The module offers various features such as creating, editing, and deleting email accounts, managing permissions for email addresses, managing email retention policies, and managing email routing. Once you have successfully installed and connected to the module, you can start managing your Exchange Online environment using PowerShell commands. The module contains a variety of cmdlets that make it easy to perform administrative tasks like creating new mailboxes, managing groups, and configuring email settings. Some of the most popular cmdlets include:

  • Get-Mailbox: This cmdlet can retrieve information about a mailbox, such as the display name, email address, and mailbox size.
  • Get-MailboxStatistics: This cmdlet returns information about the number of messages in a mailbox, including the number of unread messages.
  • Get-Recipient: This cmdlet can be used to retrieve information about a recipient, such as the display name, email address, and Recipient Type.
  • New-Mailbox: This cmdlet can be used to create a new mailbox.
  • Set-Mailbox: This cmdlet can be used to modify an existing mailbox.
  • Remove-Mailbox: This cmdlet can be used to delete a mailbox.

These are just a few examples of the cmdlets that are available in the Exchange Online PowerShell module. For a full list of cmdlets, run the following command in PowerShell:

Get-Command -Module ExchangeOnlineManagement

This will display a list of all the cmdlets available in the module. But wait! That’s not the complete list of cmdlets available for Exchange Online. When you connect with Exchange Online, You are also opening a PSSession to a remote Exchange server. The ExchangeOnlineManagement module offers a core group of cmdlets from the remote server. So, to get a list of all Exchange Online cmdlets from the PSSession use this PowerShell script:

#Connect to Exchange Online
Connect-ExchangeOnline -UserPrincipalName "Salaudeen@Crescent.com" -ShowProgress $false

#Get the Module
$Module =  Split-Path (Get-ConnectionInformation | Select -ExpandProperty ModuleName) -leaf

#Get All cmdlets from Remote Exchange Server
Get-Command -Module $Module

Use Exchange Online PowerShell to display mailbox information

You can access Exchange Online and perform various management tasks, such as Manage Mailbox, Create or Edit email address policies, set mailbox permissions, configuring settings, view mailbox properties, apply policies, and more. The module also allows admin access to mailbox settings and provisioning settings. Let’s see how to use the Exchange Online PowerShell module to get information about your email accounts. After connecting to Exchange Online, use the “Get-Mailbox” cmdlet to get all available mailboxes in your environment.

Get-Mailbox

If everything works correctly, you should see a list of mailboxes in your Exchange Online environment (equivalent to Get-EXOMailbox cmdlet).

install exchange online powershell module

The Exchange Online cmdlets are pretty helpful in performing micro-admin tasks quickly and easily.

Disconnect Exchange Online

Once you finish Exchange Online Admin activities, You can disconnect the session to free up some resources or connect to a different tenant. To disconnect the Exchange Online PowerShell session on your local machine, you run the following command in PowerShell:

Disconnect-ExchangeOnline

This will clean up the current session object and local files and remove the access token from the cache. Closing the PowerShell window without disconnecting the session is not the best practice, as this could leave a malicious party open access to your system. Once disconnected, you won’t be able to execute any cmdlet or PowerShell scripts for Exchange Online.

Update the Exchange Online PowerShell Module

Microsoft regularly updates the Exchange Online PowerShell module with new features and bug fixes. If you’re using Exchange Online, keeping your PowerShell module up-to-date with the latest features and updates is important. To update to the latest version of the Exchange Online PowerShell module, use the following command:

Update-Module -Name ExchangeOnlineManagement

This will ensure they are using the latest version of the Exchange Online Module. Once the updates are installed, you can run the command ‘Get-InstalledModule -Name ExchangeOnlineManagement’ to verify that the update was successful.

Uninstall the Exchange Online PowerShell module

If you no longer need to use the Exchange Online PowerShell module, you can uninstall it! To remove the Exchange Online PowerShell Module from your system, follow these steps: Open Windows PowerShell on your computer. You can do this by typing “PowerShell” into the search bar on your taskbar and selecting “Windows PowerShell” from the results.

Execute the following command in PowerShell to uninstall the Exchange Online PowerShell module:

Uninstall-Module -Name ExchangeOnlineManagement -AllVersions

This will remove the module from your system. Use the “-Force” parameter if you encounter errors during uninstallation. The full command would be: “Uninstall-Module -Name ExchangeOnlineManagement -Force”. This will completely remove the module from your system.

Before uninstalling the Exchange Online PowerShell module, ensure no PowerShell console or PowerShell ISE is open. Otherwise, You’ll get an error message “WARNING: The version ‘3.1.0’ of module ‘ExchangeOnlineManagement’ is currently in use. Retry the operation after closing the applications.”

Troubleshooting tips for Exchange Online PowerShell connection issues

Here are some troubleshooting tips that you can use to resolve issues while connecting to Exchange Online PowerShell:

  • Check the credentials: Ensure that you’re using the correct administrator credentials to connect.
  • Disable MFA: If you’re using MFA, try disabling it temporarily and connect using regular credentials. You can also try the app password to connect – Ideal for automation and unattended scripts.
  • Check firewall restrictions: Ensure the ports are open on your computer and network to connect to Exchange Online PowerShell.
  • Reinstall the module: If the module is not installed or not functioning correctly, reinstall the module using the Install-Module cmdlet with “-Force” switch.

Best practices for using Exchange Online PowerShell

Here are some best practices that you should follow while using Exchange Online PowerShell:

  • Use a test environment: Always test your scripts and commands in a test environment before running them in a production environment.
  • Use the -WhatIf parameter: Use the -WhatIf parameter to preview the changes that your command or script will make before executing it.
  • Use comments: Make use of comments in your scripts to explain what your script does and to make it easier to understand.
  • Use variables: Use variables to store values that you repeatedly use in your scripts.

Conclusion

In this article, we have discussed how to install the Exchange Online PowerShell module on your computer. We also discussed the prerequisites, common issues faced while connecting, and best practices to follow while using Exchange Online PowerShell. Exchange Online PowerShell is a handy tool for managing your Office 365 tenants. Installing it doesn’t have to be complicated or time-consuming, and this article has provided you with all the information you need to get started. Whether you’re a novice or an experienced user, following these steps guarantees you can efficiently use the Exchange Online PowerShell module quickly and easily. By following the steps outlined in this guide, you can quickly and easily install the Exchange Online PowerShell module and manage your Exchange Online organization using PowerShell. This can be a useful tool for managing and maintaining your Exchange Online organization and improving productivity.

The ability to configure settings, create users, assign licenses, and more via PowerShell commands quickly makes this one of the most powerful tools for administrators in their day-to-day management tasks. Take advantage of this feature today and start getting more out of your Office 365 experience! The possibilities are endless! Be sure to check the Exchange Online PowerShell documentation for the available PowerShell cmdlets.

How do I Connect the Exchange Online 365 to PowerShell?

To connect to Exchange Online PowerShell, you need to have the Exchange Online Remote PowerShell Module installed on your computer. Once you have that installed, you can open PowerShell and run the command “Connect-ExchangeOnline” to connect to Exchange Online. You will need to enter your Office 365 admin credentials to authenticate the connection.

Is the Exchange Online PowerShell Module compatible with Windows 10?

Yes, the Exchange Online PowerShell Module is compatible with Windows 10.

What permissions do I need to install the Exchange Online PowerShell Module?

To install the Exchange Online PowerShell Module, you need to have “Administrator” permissions on the local PC. You need the Global administrator or Exchange administrator role in Office 365 to connect to Exchange Online from PowerShell.

Does the Exchange Online PowerShell Module require an internet connection?

Yes, the Exchange Online PowerShell Module requires an internet connection to connect to the Exchange Online service.

How to install get-module in PowerShell?

To install the Get-Module cmdlet in PowerShell, you don’t need to do anything special. It is included by default in PowerShell versions 3.0 and above. Simply open PowerShell and start using the Get-Module cmdlet to manage and work with modules.

How to check if a PowerShell module is already installed?

Use the Get-InstalledModule or Get-Module cmdlet with the -ListAvailable parameter to check if a module is installed and available to the current PowerShell session. For example, to check if the SomeModule is installed, type Get-Module -ListAvailable -Name SomeModule. If the module is installed, it will display information about the module. If it is not installed, it will not display anything.

How do I check my Exchange Online PowerShell version?

To check your Exchange Online PowerShell version, you can use the Get-InstalledModule cmdlet. Open PowerShell and run the command “Get-InstalledModule -Name ExchangeOnlineManagement” to see the version information.

Salaudeen Rajack

Salaudeen Rajack - Information Technology Expert with Two-decades of hands-on experience, specializing in SharePoint, PowerShell, Microsoft 365, and related products. He has held various positions including SharePoint Architect, Administrator, Developer and consultant, has helped many organizations to implement and optimize SharePoint solutions. Known for his deep technical expertise, He's passionate about sharing the knowledge and insights to help others, through the real-world articles!

Leave a Reply

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