-
Notifications
You must be signed in to change notification settings - Fork 247
Update all Microsoft Cloud PowerShell modules
This guide explains how to use the o365-update.ps1 script to install, update, and clean up Microsoft Cloud PowerShell modules (Graph, Exchange Online, Teams, SharePoint, Az, and more). It reflects the latest script changes (v2.10) with PowerShell 7-only support and an improved elevation experience.
- PowerShell 7.0 or higher (PS5 is not supported)
- Administrator privileges (system-wide module management uses AllUsers scope)
- Internet connectivity to PowerShell Gallery and Microsoft endpoints
- Sufficient disk space (2+ GB recommended for large modules like Az/Graph)
You can check your version with:
$PSVersionTable.PSVersion- Open PowerShell 7 as Administrator (Start Menu → search "PowerShell 7" → right‑click → Run as administrator).
- Run the script from the repo folder:
.\o365-update.ps1If you started in a non-admin session, the script prints a friendly message and a ready‑to‑copy elevation command. You can paste and run it to relaunch elevated:
Start-Process -Verb RunAs pwsh -ArgumentList @('-NoProfile','-ExecutionPolicy','Bypass','-File', 'C:\Downloads\source\Office365\o365-update.ps1')Replace the path with your script’s full path if different.
- Installs or updates Microsoft Cloud modules: Microsoft.Graph (+ Authentication), ExchangeOnlineManagement, MicrosoftTeams, PnP.PowerShell, Az, SharePoint Online Admin, WinGet client, etc.
- Removes deprecated modules automatically (AzureAD, AzureADPreview, MSOnline, AIPService, aadrm, SharePointPnPPowerShellOnline, WindowsAutoPilotIntune, O365CentralizedAddInDeployment, MSCommerce).
- Optimizes downloads (TLS 1.2, higher connection limits) and shows progress with time estimates.
- Handles core module updates (PowerShellGet, PackageManagement) using conflict‑free, side‑by‑side installs.
- Optionally cleans up old module versions automatically to prevent multi‑version conflicts.
- Provides connectivity checks and clear troubleshooting guidance.
-
-Prompt: Ask before installing or cleaning up; interactive prompts for multi‑version cleanup. -
-CreateLog: Start transcript logging (path printed at start). Use-LogPathto specify directory. -
-LogPath <dir>: Target folder for transcript logs when-CreateLogis used. -
-SkipDeprecatedCleanup: Skip removal of deprecated modules. -
-SkipVersionCleanup: Skip automatic cleanup of old versions after updates. -
-CheckOnly: Report current/online versions without installing/updating. -
-CheckSessions: Only check for PowerShell session conflicts and exit. -
-TerminateConflicts: Automatically close conflicting PowerShell sessions (when supported). -
-ModuleScope <All|Graph|Azure|Exchange|Teams|SharePoint|PowerApps>: Limit which module categories are processed. -
-SkipConnectivityCheck: Skip network connectivity tests. -
-Repository <name>: Target repository (default:PSGallery).
- Update everything, no prompts:
.\o365-update.ps1- Review actions interactively, preserve multiple versions:
.\o365-update.ps1 -Prompt -SkipVersionCleanup- Only check versions, don’t change anything:
.\o365-update.ps1 -CheckOnly- Target just Graph + Exchange:
.\o365-update.ps1 -ModuleScope Graph,Exchange- Create a log file in a specific folder:
.\o365-update.ps1 -CreateLog -LogPath 'C:\Logs'-
Graph:
Microsoft.Graph,Microsoft.Graph.Authentication -
Exchange:
ExchangeOnlineManagement -
Teams:
MicrosoftTeams -
SharePoint:
PnP.PowerShell,Microsoft.Online.SharePoint.PowerShell -
Azure:
Az -
PowerApps:
Microsoft.PowerApps.PowerShell,Microsoft.PowerApps.Administration.PowerShell -
Core:
PowerShellGet,PackageManagement -
Other:
Microsoft.WinGet.Client
-
AzureAD,AzureADPreview,MSOnline,AIPService,aadrm,SharePointPnPPowerShellOnline,WindowsAutoPilotIntune,O365CentralizedAddInDeployment,MSCommerce
Large modules (e.g., Az, Microsoft.Graph) include more detailed progress and time estimates. In restricted environments, verification phases can appear to “hang” — this is normal; do not cancel. The script prints clear phase information and reminders.
By default, after a successful install/update the script removes older versions to avoid conflicts. Use -SkipVersionCleanup to keep multiple versions, or run interactive cleanup with -Prompt. There is also a comprehensive cleanup option at the end when using -Prompt.
The script can test connectivity to:
- PowerShell Gallery (www.powershellgallery.com)
- Microsoft Download Center (download.microsoft.com)
- NuGet.org (api.nuget.org)
Failures won’t necessarily block updates, but they can slow or break operations. You can skip these checks using -SkipConnectivityCheck.
- Not running as Administrator
- The script will instruct you to relaunch elevated and shows a copy‑ready command.
- PowerShell 5.x errors
- The script requires PS 7+. Install PowerShell 7 and rerun.
- Core module "currently in use" messages (PowerShellGet/PackageManagement)
- The script safely installs the newer version side‑by‑side and advises restarting PowerShell to use it.
- Command conflicts (AllowClobber)
- The script detects conflicts and retries with
-AllowClobberwhen possible.
- The script detects conflicts and retries with
- Slow installs for Az/Graph
- Normal for large modules; verification can take minutes. Ensure stable connectivity and disk space.
- Corporate environments (policy/WDAC/AppLocker)
- Execution policy and language mode restrictions may slow or block some optimizations. Run elevated PS7 and consult your administrator if needed.
- Modern modules and tooling are optimized for PowerShell 7.
- PS 7 provides improved performance, compatibility, and error handling.
- Avoids parser differences and limitations in Windows PowerShell 5.1.
Install PowerShell 7:
- Enforced PowerShell 7+ support (
#Requires -Version 7.0). - Replaced
#Requires -RunAsAdministratorwith a friendly, actionable elevation check. - Printed a safe, copyable elevation command using array‑form
-ArgumentList. - Tightened prerequisite checks to require PS 7+.
- Improved non‑admin experience with clear steps and rationale.
- Automatic cleanup of old module versions after updates.
- Interactive cleanup prompts with
-Promptand end‑of‑run comprehensive cleanup. - Added
Remove-OldModuleVersionsandRemove-AllOldModuleVersionshelpers.
- Consolidated session conflict detection/handling and removed duplicate prompts.
- Fixed compatibility by removing
??(null coalescing) for older hosts.
- Eliminated noisy “PackageManagement is currently in use” warnings.
- Comprehensive suppression of output streams during core module updates.
(See inline script comments for prior versions.)
- After updates, restart PowerShell to pick up new core module versions.
- Verify installations:
Get-Module -ListAvailable PowerShellGet,PackageManagement,Microsoft.Graph,ExchangeOnlineManagement,MicrosoftTeams,PnP.PowerShell,Az | Select Name,Version | Sort Name- Review logs if
-CreateLogwas used (path printed at start).
- Script (source): https://github.com/directorcia/Office365/blob/master/o365-update.ps1
- This page (wiki replacement): Update-all-Microsoft-Cloud-PowerShell-modules
- PowerShell 7 install: https://learn.microsoft.com/powershell/scripting/install/installing-powershell
- Home: https://github.com/directorcia/Office365/wiki
- Connect to Microsoft Cloud Services: https://github.com/directorcia/Office365/wiki/Connect-to-Microsoft-Cloud-Services
- Remove all current PowerShell sessions: https://github.com/directorcia/Office365/wiki/Remove-all-current-PowerShell-sessions
- Microsoft 365 Connection Speed Test: https://github.com/directorcia/Office365/wiki/Microsoft-365-Connection-Speed-Test
- Login audit: https://github.com/directorcia/Office365/wiki/Login-audit
- Get tenant signins: https://github.com/directorcia/Office365/wiki/Get-tenant-signins
- Email Header Report Tool: https://github.com/directorcia/Office365/wiki/Email-Header-Report-Tool
- ASD OWA Mailbox Configuration Check: https://github.com/directorcia/Office365/wiki/ASD-OWA-Mailbox-Configuration-Check
- ASD Remote Domain Configuration Check: https://github.com/directorcia/Office365/wiki/ASD-Remote-Domain-Configuration-Check