How to: Viewing which repositories have branch policies on Azure DevOps

$ProjectsResult = az devops project list --org $Organization | ConvertFrom-Json 
Foreach ($project in $ProjectsResult.value)
{
Write-Host $project.id
}
$ReposResult = az repos list --org $Organization --project $project.id | ConvertFrom-Json
Foreach ($repo in $ReposResult)
{
Write-Host $repo.id
}
$ReposPolicyResult = az repos policy list --branch $repo.defaultBranch --org $Organization --project $project.id --repository-id $repo.id | ConvertFrom-Json
Foreach ($repoPolicy in $ReposPolicyResult)
{
Write-Host $repoPolicy.type.displayName
}
{
"RepositoryId": "[Repository ID]",
"RepositoryDefaultBranchRequiredReviewers": true,
"RepositoryDefaultBranchCommentRequirements": true,
"TeamProjectName": "[Team Project Name]",
"TeamProjectId": "[Team Project Id]",
"RepositoryDefaultBranchWorkItemLinking": true,
"RepositoryURL": "[Repo URL]",
"RepositoryDefaultBranch": "refs/heads/master",
"RepositoryName": "WorkItemDeployment",
"RepositoryDefaultBranchBuild": true,
"RepositoryDefaultBranchMinimumNumberOfReviewers": true
}

--

--

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