How to: List GitHub default Branch protection rules

$uriRepositories = "$($UriOrganization)/repos"$RepositoriesResult = Invoke-RestMethod -Headers $headers -Uri $uriRepositoriesforeach ($repo in $RepositoriesResult)
{
Write-Host $repo.name
Write-Host $repo.default_branch
}
$uriDefaultBranch = $repo.branches_url.Replace('{/branch}',"/$($repo.default_branch)")    $DefaultBranchResults = Invoke-RestMethod -Headers $headers -Uri $uriDefaultBranch    if ($DefaultBranchResults.protected)
{
Write-Host $DefaultBranchResults.protection_url
}
$branchProtectionResults = Invoke-RestMethod -Headers $headers -Uri $DefaultBranchResults.protection_url        
If ($branchProtectionResults)
{
$allow_deletions = $branchProtectionResults.allow_deletions.enabled
}

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store