M365 PowerShell Setup
Install PowerShell and the modules Microsoft 365 admin work needs, then connect to each service — top to bottom, no account needed. Optional update and uninstall/reinstall steps are there if something needs fixing.
Every module below needs current, cross-platform PowerShell (7+) — not the older 5.x powershell.exe
that ships built into Windows.
Latest release on GitHub Microsoft install docs
Linux: installation varies by distribution (APT/YUM/Zypper/Snap packages, or a portable tarball) — see the Microsoft install docs link above for your specific distro.
Already installed? Check your version and upgrade if needed:
Check the modules you need — this drives the update, uninstall, and connect commands in Steps 3, 4, and 5.
Commands use -Force to skip the PSGallery untrusted-repository confirmation prompt.
Not sure what you already have? List every installed module and its version before installing anything:
Still current and supported for SharePoint Online tenant administration — but some newer capabilities are only available through Microsoft Graph PowerShell or PnP PowerShell.
See what's currently installed, then update just the modules you're using.
Side-by-side installs: Update-Module installs the new version alongside the old
one — old versions aren't removed automatically. Cleaning them up is optional housekeeping:
Loaded-module gotcha: a module already loaded in the current session can't be cleanly updated. Close every PowerShell window and run the update from a fresh, elevated session.
A full uninstall and reinstall is the standard fix for a corrupted or version-conflicted module. Run these from an elevated PowerShell session with no other PowerShell windows open.
Commands use -Force to skip the confirmation prompt.
Each command above uses -AllVersions, so it also cleans up any side-by-side leftovers from
Step 3's update gotcha.
To reinstall, use Step 2's Install-Module commands for the
module(s) you checked there.
Fills in the connect commands below that need a tenant subdomain.
Connected? Browse the command reference M365 PowerShell Commands →