Microsoft 365 — Overview & Connection
Scripts in this section administer the major Microsoft 365 workloads — Entra ID, Exchange Online, SharePoint, OneDrive, Teams, Intune, Purview, and Defender. Before the per-workload scripts, this page covers how to connect cleanly and securely.
Modules per workload
Microsoft 365 has no single PowerShell module; each workload has its own. Install only what you need:
| Workload | Module | Install |
|---|---|---|
| Entra ID, Intune, Defender, reports | Microsoft.Graph | Install-Module Microsoft.Graph |
| Exchange Online, Purview (audit/DLP) | ExchangeOnlineManagement | Install-Module ExchangeOnlineManagement |
| SharePoint / OneDrive (PnP) | PnP.PowerShell | Install-Module PnP.PowerShell |
| SharePoint admin (classic) | Microsoft.Online.SharePoint.PowerShell | Install-Module Microsoft.Online.SharePoint.PowerShell |
| Teams | MicrosoftTeams | Install-Module MicrosoftTeams |
Tip — Install scope
Install for the current user to avoid needing admin rights on shared hosts:
Install-Module <name> -Scope CurrentUser. Keep modules updated — the Graph SDK in particular changes quickly.
Interactive vs app-only authentication
- Interactive (
Connect-MgGraph -Scopes ...,Connect-ExchangeOnline -UserPrincipalName ...) is fine for ad-hoc, attended work. It runs as you, with your roles, and prompts for MFA. - App-only / certificate-based is the right choice for unattended automation (scheduled tasks, runbooks). Register an Entra app, grant it the minimum application permissions, and authenticate with a certificate — never a client secret in a script. This avoids storing credentials and keeps automation auditable.
Least privilege
Request only the scopes/permissions a script needs, and prefer read-only
scopes for reporting. For example, a script that only reports on users needs
User.Read.All, not User.ReadWrite.All. Over-scoped automation is a standing
risk — and exactly the kind of thing an identity-hardening baseline exists to contain.
Workloads
Each workload is a folder, and each script has its own page beneath it.
| Workload | Scripts | What the section covers |
|---|---|---|
| Entra ID | 5 | Enterprise app hygiene, privileged roles, authentication strength, Conditional Access, guests |
| Exchange Online | 4 | Delegation and forwarding, mail flow rules and connectors, mailbox sizing, shared mailbox exposure |
| SharePoint Online | 4 | External sharing, storage and growth, orphaned sites, site collection admins |
| OneDrive | 3 | Storage and orphaned data, external sharing, leaver drive access |
| Teams | 4 | Ownership and guests, inactive teams, policy assignments, external access |
| Intune | 4 | Compliance and sync, BitLocker escrow, profile assignments, app deployment |
| Purview | 4 | Audit log export, retention, DLP coverage, sensitivity labels |
| Defender | 4 | Policy coverage, allow and block lists, impersonation protection, quarantine |
Every script is read-only unless its page says otherwise, writes a CSV to
C:\Temp, and leaves a timestamped run log beside it. Each workload's overview
page says which module to connect with and what to do first.
A note on what these report
Each of these answers a question an admin centre answers badly or not at all — usually because the answer requires joining two things the portal shows on separate screens. The recurring theme is the difference between configured and effective:
- a DLP policy that exists but is still in test mode
- a device reporting compliant that hasn't checked in since winter
- a sharing setting capped by a tenant ceiling that will loosen the day someone raises it
- an Intune profile assigned to an empty group
- a sensitivity label published to nobody
- a mailbox whose account can still sign in
Those gaps are where the portal's green ticks stop meaning anything, and they're the reason these exist.
A warning that applies to all of them
These are starting points to read before you run, not turnkey tools for your tenant. They have been written carefully and checked for syntax; they have not been run against every tenant shape, and Microsoft renames properties and retires endpoints regularly. The caveats section on each page is where the known sharp edges are recorded — read it before trusting the output, and especially before treating an empty result as good news.