Skip to main content

Script Repository

A curated, audience-neutral library of PowerShell for administering Windows and Microsoft 365. Like the rest of the documentation, this is a single source of truth: scripts are written to a common standard so they're predictable, safe to run, and produce evidence you can keep.

Conventions

All scripts in this repository are written to a common standard:

  • Functional style. Logic lives in named functions with approved verbs; the bottom of the script orchestrates them.
  • [CmdletBinding()] and parameters. Scripts are parameterised, support -Verbose/-Debug, and where they change state they support -WhatIf via SupportsShouldProcess.
  • Fail fast. $ErrorActionPreference = 'Stop' with try/catch around the work, so a failure is logged and surfaced rather than silently skipped.
  • Logging to C:\Temp. Every run writes a timestamped log — verbose, greppable, and kept as evidence.
  • #Requires. Scripts declare their PowerShell version and module dependencies so they fail clearly on the wrong host.

Running these safely

  • Read before you run. These are starting points, not turnkey tools for your exact tenant. Review every script against your environment.
  • Pilot first. Run read-only/reporting scripts before anything that changes state, and use -WhatIf where it's offered.
  • Least privilege. Connect with an account or app that has only the rights the task needs; prefer certificate-based app authentication for anything unattended.
  • Execution policy. Sign your scripts where you can; otherwise run with an appropriately scoped Set-ExecutionPolicy -Scope Process rather than weakening the machine default.

Sections

  • Windows — endpoint and server administration.
  • Microsoft 365 — Entra ID, Exchange Online, SharePoint, OneDrive, Teams, Intune, Purview, and Defender.