How to: List GitHub Repositories and master protection rules

Use this PowerShell cmdlet to list all repositories on GitHub and respective master protection rules

After show you how to create a repository and policies on Azure DevOps, I will explorer GitHub Rest API, focused on branches.

In this example, I will list all repositories associated with a user and verify the respective master protection rules on each repository.

To do this, we should create initially a personal access token. To do this, access your Settings:

After this, choose Developer settings:

And finally, click on “Personal access tokens”, “Generate new token”:

Set a respective name on Note and set permission on the repo. After that, click on generate a token (don’t forget to copy the token value).

Use the script below to list all repositories and respective master protection rules of each repository (use personal access token generated above on this script):