When finished, disconnect cleanly:
Disconnect-ExchangeOnline For those who prefer a single, cross-platform CLI (works in CMD, bash, or zsh), Microsoft offers the Microsoft Graph CLI ( mgc ). It’s lighter than full PowerShell and doesn’t require a separate scripting environment. Installation (Windows CMD) Run as administrator in CMD: microsoft 365 cmd
powershell Then, install the Exchange Online Management module (one-time setup): You’ll never look at the web admin portal
Connect-ExchangeOnline -UserPrincipalName admin@yourdomain.com Once connected, you can run powerful commands directly: winget install Microsoft
Open CMD, type powershell , and run Connect-ExchangeOnline . You’ll never look at the web admin portal the same way again. Have a favorite Microsoft 365 command-line trick? Share it with the community below.
winget install Microsoft.Graph.CLI Or with npm:
npm install -g @microsoft/microsoft-graph-cli mgc login Once logged in, you can manage almost any aspect of Microsoft 365: