PowerShell 7.x is the modern, cross-platform automation tool from Microsoft, built on the latest .NET framework. Unlike the legacy Windows PowerShell 5.1 which is locked to the Windows operating system, PowerShell 7 runs natively on Windows, macOS, and Linux, giving administrators a consistent scripting environment across their entire infrastructure. This guide walks through the complete installation and configuration process for using PowerShell 7 to manage Microsoft 365.
Why Upgrade to PowerShell 7 for Microsoft 365 Management?
Modernizing to PowerShell 7 provides critical advantages for Microsoft 365 administrators:
- Cross-Platform Support. Run the same management scripts on Windows, macOS, and Linux without modification, enabling consistent automation across heterogeneous environments.
- Performance Improvements. PowerShell 7 is built on modern .NET versions (PowerShell 7.6 on .NET 10.0 LTS), delivering faster execution and better memory efficiency compared to Windows PowerShell 5.1.
- Native Module Compatibility. The ExchangeOnlineManagement module (EXO V2+), Microsoft Graph PowerShell SDK, and other modern M365 modules are fully supported in PowerShell 7, making it a first-class choice for cloud administration.
- Future-Proof Automation. Microsoft continues active development on PowerShell 7, while Windows PowerShell 5.1 receives only security updates. PowerShell 7 is the platform where new features and modules will land.
- Side-by-Side Installation. PowerShell 7 installs alongside Windows PowerShell 5.1, allowing you to test scripts safely without removing the legacy version.
What You’ll Configure
You will install PowerShell 7.x on your operating system of choice, install the necessary Microsoft 365 management modules, and configure secure authentication to your tenant. To perform these actions, you will need:
- Windows 10, Windows 11, Windows Server 2016 or later (for Windows).
- An administrative account on your local machine (for module installation).
- A Microsoft 365 Global Administrator or appropriate delegated admin account (for connecting to services).
- Internet access to the PowerShell Gallery (PSGallery) and Microsoft authentication endpoints.
Step 1: Install PowerShell 7.x
The installation method depends on your operating system. Choose the section that matches your environment.
Important Version Note for M365 Management
If you plan to manage Exchange Online, note that ExchangeOnlineManagement module versions 3.5.0 or later require PowerShell 7.4.0 or later due to .NET 8.0 dependencies. Version 3.0.0 through 3.4.0 require PowerShell 7.2.x (.NET 6.0). Installing the latest PowerShell 7.x (currently 7.6) is strongly recommended for best compatibility.
Windows Installation
On Windows 10, Windows 11, or Windows Server 2025, the recommended method is using WinGet, the Windows Package Manager:
- Open an elevated PowerShell 7 or Windows PowerShell prompt.
- Run the following command to install PowerShell 7:
winget install --id Microsoft.PowerShell --source winget- Once installed, launch PowerShell 7 by typing pwsh in your terminal or finding it in the Start Menu.
For Windows Server 2022 or earlier (where WinGet is not available), or for enterprise deployment scenarios, download and run the MSI package from the official GitHub releases page.
Note: PowerShell 7 does not replace Windows PowerShell 5.1. It installs to a new directory and runs side-by-side with the legacy version, allowing safe script testing.
Step 2: Verify PowerShell 7 Installation
Once installed, open a new terminal (or Command Prompt) and launch PowerShell 7 by typing pwsh. Run the following command to confirm your version:
powershell
$PSVersionTable.PSVersionFor Microsoft 365 management, you should see 7.4 or higher (ideally 7.6 or the latest LTS release). Example output:
Major Minor Patch PreReleaseLabel BuildLabel
----- ----- ----- ---------------- ----------
7 6 2Step 3: Install Required Microsoft 365 PowerShell Modules
With PowerShell 7 installed, you can now install the modules required to manage specific Microsoft 365 workloads. Run all installation commands from an elevated (administrator) PowerShell 7 session (“Run as administrator” on Windows).
Exchange Online Management (EXO V2+)
The ExchangeOnlineManagement module (commonly called EXO V2+) is required for managing mailboxes, transport rules, and other Exchange Online settings:
Install-Module -Name ExchangeOnlineManagement -Force -AllowClobberThis module is supported in PowerShell 7 on Windows, macOS, and Linux, making it truly cross-platform.
Microsoft Graph PowerShell SDK
The Microsoft Graph PowerShell SDK is the modern, recommended way to manage Entra ID (Azure AD), users, groups, licenses, and any resource exposed through the Microsoft Graph API:
Install-Module Microsoft.GraphFor large tenants, you can install only the sub-modules you actually use (e.g., Microsoft.Graph.Users, Microsoft.Graph.Groups) to reduce memory footprint.
SharePoint Online Management
For SharePoint Online administration (site collections, sharing settings, storage quotas), install the dedicated SharePoint Online Management Shell:
Install-Module -Name Microsoft.Online.SharePoint.PowerShellImportant: While Microsoft Graph PowerShell has some SharePoint-related beta cmdlets, they are not yet considered production-ready for SharePoint administration. The Microsoft.Online.SharePoint.PowerShell module remains the recommended and fully supported option.
Teams PowerShell Module
If you manage Microsoft Teams, install the Teams PowerShell module:
Install-Module -Name MicrosoftTeams(Legacy) MSOnline Module for Older Scripts
The older MSOnline module (Azure Active Directory module for PowerShell) is still used by some legacy scripts, but Microsoft Graph PowerShell SDK is the recommended replacement for all new development. To install the legacy module if absolutely necessary:
Install-Module -Name MSOnlineStep 4: Configure Execution Policy (Windows Only)
On Windows, PowerShell’s execution policy may block script execution. To allow local scripts to run while maintaining security, set the execution policy for the CurrentUser scope:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUserThis setting allows locally created scripts to run without signing, while requiring remote scripts to be signed by a trusted publisher.
Step 5: Connect to Your Microsoft 365 Services
Once the required modules are installed, you can connect to individual services using their dedicated Connect-* cmdlets.
Connect to Exchange Online
Connect-ExchangeOnlineA browser window will open for authentication. Enter your Microsoft 365 admin credentials and complete any Multi-Factor Authentication (MFA) prompts. After successful authentication, your session is connected.
Connect to Microsoft Graph (Entra ID / Users / Groups)
Connect-MgGraph -Scopes "User.Read.All", "Group.ReadWrite.All", "Directory.Read.All"The -Scopes parameter specifies the permissions your session requests. You can add or remove scopes based on your administrative needs. After connecting, you can run commands like Get-MgUser -Top 10 to verify access.
Connect to SharePoint Online
Connect-SPOService -Url https://<yourtenant>-admin.sharepoint.comReplace <yourtenant> with your Microsoft 365 tenant name. Note the -admin portion in the URL – this is mandatory and a common mistake is using the regular SharePoint URL instead.
Connect to Microsoft Teams
Connect-MicrosoftTeamsStep 6: Verify Your Connections
Run simple cmdlets to confirm that each connection is working correctly:
| Service | Verification Command |
| Exchange Online | Get-Mailbox -ResultSize 5 |
| Microsoft Graph | Get-MgUser -Top 5 -Property DisplayName,UserPrincipalName |
| SharePoint Online | Get-SPOSite -Limit 5 |
| Teams | Get-Team -Limit 5 |
Wrap-up
You can install and configure PowerShell 7.x for Microsoft 365 management by downloading and installing the cross-platform shell on Windows, macOS, or Linux, then adding the specific modules required for your workloads (ExchangeOnlineManagement, Microsoft Graph, SharePoint Online, Teams). Ensure your PowerShell 7 version is 7.4 or later for full compatibility with the latest module versions. Use this configuration to centralize your administrative tasks, automate bulk operations, and maintain consistent management across your entire Microsoft 365 tenant from any operating system.
A Note on Version Compatibility: If you encounter errors connecting to Exchange Online, verify that your PowerShell 7 version matches the requirements of your installed ExchangeOnlineManagement module. Module versions 3.5.0 and later require PowerShell 7.4+, while versions 3.0.0-3.4.0 require PowerShell 7.2+. Downgrading the module or upgrading PowerShell 7 will resolve most compatibility issues.