-1

I created a customized team group in ADO and tried to add the team administrator by using azure cli but didn't find any related az devops command! is there any way to add the team administartor by using azure cli?

Kumar
  • 11
  • 1

2 Answers2

6

You can do it by assigning the users the correct permissions on the team's security namespace. Here's an example that adds two users as admins to a new team.

$myOrg = "https://dev.azure.com/myOrg/"
$newTeam = "My New Team"
$newAdmin = "user1@me.com"
$newAdmin2 = "user2@me.com"
$myProject = "My Project"

az login

$team = az devops team create --name $newTeam --org $myOrg --project $myProject | ConvertFrom-Json

$user = az devops user show --user $newAdmin  --organization $myOrg | ConvertFrom-Json
az devops security group membership add --group-id $team.identity.subjectDescriptor --member-id $user.user.descriptor --org $myOrg
az devops security permission update --id "5a27515b-ccd7-42c9-84f1-54c998f03866" --subject $user.user.principalName --token "$($team.projectId)\$($team.id)" --allow-bit 31  --org $myOrg

$user = az devops user show --user $newAdmin2 --organization $myOrg | ConvertFrom-Json
az devops security group membership add --group-id $team.identity.subjectDescriptor --member-id $user.user.descriptor --org $myOrg
az devops security permission update --id "5a27515b-ccd7-42c9-84f1-54c998f03866" --subject $user.user.principalName --token "$($team.projectId)\$($team.id)" --allow-bit 31  --org $myOrg
David
  • 93
  • 4
0

is there any way to add the team administartor by using azure cli?

No, it's not available to add team administrator using Azure CLI.

Use below command in CLI and you will see all the commands available at current time where "add team administrator" is not included:

PS C:\Users\***> az devops team -h

Group
    az devops team : Manage teams.

Commands:
    create      : Create a team.
    delete      : Delete a team.
    list        : List all teams in a project.
    list-member : List members of a team.
    show        : Show team details.
    update      : Update a team's name and/or description.

The most convenient way to add team administrator should be through the UI.

In addition, you can achieve this by using the Rest Api which you can refer to How to add Team administrator through Azure DevOps REST API? Follow the steps in the suggested solution and you will be able to add specific team administrator.(The request body should be {"teamId":"{teamId}","newUsersJson":"[\"{userId}\"]","existingUsersJson":"[]"}., the solution seems has this little mistake.)

Yang Shen - MSFT
  • 1,136
  • 1
  • 7
  • 9