How to: Extract Organization Level Permissions from the respective user in Azure DevOps

This script and report extract Organization Level Permissions from the user. Before that, it’s necessary to get all groups to which that user belongs.

DISCLAIMER: Due to the number of records generated by this report, one mandatory filter was placed: the name of the user. This report was based on the ALM Rangers project Extracting effective permissions from TFS. Within Azure DevOps, click on Organization Settings, after clicking in Permissions, and select a respective group.

An original script is available on my GitHub repository. See below this script:

Let’s go understand each command used.

  1. PowerShell script will receive the following parameters:
  • $PAT = Personal Access token to connect on Azure DevOps;
  • $Organization = Organization URL to list permissions on Organization Level;
  • mailAdress = e-mail from respective user to which permissions will be extracted;
  • $Connstr = connection string to Azure SQL Database to store the report information. To create this report, it’s necessary to create previously a Azure SQL Server and Database and run a script below:

2. az devops user list = use this command to list all users on Azure DevOps organization. After that, it’s necessary to filter a respective user that was received by parameter.

3. az devops security group membership list = use this command to list all groups that user (received by parameter) is contained in.

4. In Azure DevOps, when working with permissions, it’s necessary to understand SecurityNameSpaces. Basically, each namespace represents the respective set of permissions on Azure DevOps (Git, Area Path, Project Level, Iterations, Builds, Releases, etc.). To this example, to represent permission on Organization Level will be used namespaces AuditLog, Collection, BuildAdministration, Project, VersionControlPrivileges, Process, and Server, which is represented by the constants below:

5. Token = At the moment that we extract any kind of permission on Azure DevOps, it’s necessary to work with tokens. For each type of permission, there is a specific rule to produce that token. For each namespace, there is the specific rule:

  • AuditLog
  • Collection
  • BuildAdministration
  • Project
  • VersionControlPrivileges
  • Process
  • Server

6. More details about other tokens can be found in the links below:

7. az devops security permission show = Show details of permissions available in each namespace

8. After extract all permissions, this information is stored in a table in Azure SQL.

9. After insert information into a table, I connected this database on Power BI:

  • Azure DevOps Groups (1) = Filter Azure DevOps Groups to which the user belongs;
  • Azure DevOps Groups (2) = list all Azure DevOps groups to which the user belongs;
  • Permission Group Type (3) = List of Permission Group Type (General, Service Account, Boards, Repos, Pipelines, Test Plans, Auditing, Policies);
  • Command (4) = List of commands available to Organization Level;
  • Permission (5) = Permission type (Allow, Deny, Not set, etc.).

DevOps Consultant at N3