Microsoft 365 features that help users manage their subscriptions, account settings, and billing information.
PowerShell 7 can connect to Microsoft 365 services (Exchange Online, SharePoint Online, Microsoft Graph/Entra ID, Teams), but there are some version and module requirements that differ from older Windows PowerShell 5.1 guidance.
Key points for PowerShell 7 and Microsoft 365
- Use the current, supported modules
- Exchange Online: ExchangeOnlineManagement module (EXO V2+).
- Microsoft 365/Entra ID/Graph: Microsoft Graph PowerShell SDK.
- SharePoint Online: SharePoint Online Management Shell.
- Teams: Teams PowerShell module.
- PowerShell 7 version requirements for Exchange Online
The Exchange Online module has strict version dependencies in PowerShell 7:
- Support for PowerShell 7 started with ExchangeOnlineManagement 2.0.4.
- Module versions 3.0.0–3.4.0 require PowerShell 7.2.x (.NET 6.0).
- Module versions 3.5.0 or later require PowerShell 7.4.0 or later because of .NET 8.0 dependencies.
- Downgrading the module (for example, to 3.5.0) to match an older PowerShell 7 runtime, or
- Upgrading the runtime (for example, to 7.4) and using a newer module.
- PowerShell 7 vs Windows PowerShell 5.1
- All versions of the ExchangeOnlineManagement module are supported in Windows PowerShell 5.1, and the .NET Framework requirements are already met in current Windows versions.
- Because of this, many older instructions assume Windows PowerShell 5.1 and will “just work” there, while PowerShell 7 requires matching the module version to the PowerShell 7 version.
- This is why some admins recommend “go back to 5.1” or “use the older module” if PowerShell 7 is misaligned with the module version.
- Connecting to Exchange Online in PowerShell 7
After installing a compatible ExchangeOnlineManagement module for the PowerShell 7 version in use:
- Interactive sign-in (with or without MFA):
In PowerShell 7, the sign-in prompt opens in the default web browser by default (browser-based SSO).Connect-ExchangeOnline -UserPrincipalName ******@contoso.com - PowerShell 7–exclusive options include:
- Inline credentials for non-MFA accounts:
Connect-ExchangeOnline -UserPrincipalName ******@contoso.com -InlineCredential - Device login for machines without a browser:
Then complete authentication via https://microsoft.com/devicelogin with the provided code.Connect-ExchangeOnline -Device
- Inline credentials for non-MFA accounts:
- Interactive sign-in (with or without MFA):
- Prerequisites and execution policy
For Microsoft 365 PowerShell generally:
- Use a Microsoft 365 admin account (member of an appropriate admin role) when connecting.
- On Windows, configure PowerShell to run signed scripts for Exchange Online and other services:
Set-ExecutionPolicy RemoteSigned - Ensure the OS and .NET versions meet the module’s requirements. For example, PowerShell 7.2.22 (.NET 6.0) is the latest supported PowerShell 7 on some older Windows versions.
- Connecting to multiple Microsoft 365 services from one session
Microsoft provides guidance for using a single PowerShell instance to connect to:
- Microsoft 365 accounts (Graph/Entra ID)
- Exchange Online
- SharePoint Online
- Microsoft Teams
- Defender for Office 365 and Microsoft Purview compliance
- Learning resources (“crash course”)
For a structured introduction to Microsoft 365 administration with PowerShell:
- “Get started with Microsoft 365 PowerShell” explains installing modules and connecting to a subscription.
- “Manage Microsoft 365 with PowerShell” links to focused topics for Exchange Online, SharePoint, user accounts and licenses, and Security & Compliance.
In practice, the most reliable approach is:
- Decide whether to use Windows PowerShell 5.1 or PowerShell 7 for administration.
- Match the ExchangeOnlineManagement module version to the chosen PowerShell version (for PowerShell 7, respect the 7.2/7.4 requirements).
- Install the Microsoft 365 modules listed in the “Connect to all Microsoft 365 services in a single PowerShell window” guidance.
- Use the documented Connect-* cmdlets (Connect-ExchangeOnline, Microsoft Graph SDK connect, SharePoint Online connect, Teams connect) from a single session.
References: