Back to Admin Workflows

Audit GitHub Enterprise Repos and Branch Protection with PowerShell

Inventory repos, audit branch protection, surface stale teams and tokens, and report on GitHub Enterprise governance from one PowerShell workflow.

GitHub Enterprise grows faster than the governance around it. New repos get created for proofs of concept, teams get reorganized, branch protection rules drift, and personal access tokens get issued and forgotten.

PowerShell can talk to the GitHub REST API directly or through the PowerShellForGitHub module. PSForge gives you the GitHub tasks ready to assemble into a workflow that surfaces governance gaps before auditors do.

What a real GitHub audit needs to cover

  • Every repository with its owner team, visibility, and last activity
  • Branch protection on the default branch — required reviews, status checks, signed commits
  • Team membership including outside collaborators
  • Personal access tokens issued by org members and their scopes
  • Repos that have not been updated in 12+ months and are candidates for archive
  • Webhooks pointing at unknown destinations

Why this becomes a workflow

Every part of this is a single API call. The value is in running them together against the whole org and producing one report that DevOps, security, and the engineering leads can all act on.

PSForge lets you assemble the GitHub tasks into one workflow, generate the PowerShell, and schedule it from a runner so the same report lands every week.

Example GitHub Enterprise audit workflow

  1. Authenticate to GitHub with a fine-scoped PAT or GitHub App
  2. List every repository in the organization with owner team and visibility
  3. Capture branch protection rules on each default branch
  4. Enumerate teams, members, and outside collaborators
  5. List active personal access tokens with their scopes and last use
  6. Identify repositories that have not been updated in 12+ months
  7. Audit configured webhooks for each repo and flag unfamiliar destinations
  8. Send the consolidated governance report to the DevOps and security teams

Final thoughts

GitHub governance is one of those things that costs nothing to do well and a lot to do badly.

PSForge makes it easy to build a single PowerShell workflow that keeps repos, teams, branch protection, and tokens under active observation.

Related guides