How to add all iterations of a project to all teams in that project?

40 views Asked by At

How to add all iterations of a project to all teams in that project?

I know how to list all the iterations I want to add to the teams:

az boards iteration project list --depth 2 --query "children[*].children[*].identifier"

I know how to list all teams in a project:

az devops team list --query "[].id"

I know how to add an iteration to a team:

az boards iteration team add --id 76c902xxx-ca2b-4b94-ab06-ce6d3xxx8784 --team 81fxxx72-a384-453b-9ba2-1229xxxba8c6

How to add all iterations (which return the filter above with --depth 2) registered in the project to all teams in that project?

I only know how to add an iteration to a team:

az boards iteration team add --id 76c9084-ca2b-4b94-ab0xxxe6d33b68784 --team 81f0exxxa384-453b-9ba2-1229xxxba8c6

I need to know how to add all iterations to all project teams.

1

There are 1 answers

0
Ikhtesam Afrin On BEST ANSWER

I have used the given PowerShell script to add iterations of a project to all teams in that project.

$iterations = az boards iteration project list --depth 2 --query "children[*].identifier" | ConvertFrom-Json

$teams = az devops team list --query "[].id" | ConvertFrom-Json

# Iterate through each team and iteration to add them
foreach ($teamId in $teams) {
    foreach ($iterationId in $iterations) {
        $output = az boards iteration team add --id $iterationId --team $teamId
        Write-Output "Added iteration $iterationId to team $teamId"
        Write-Output $output
    }
}

I am using --query "children[*].identifier" as per my requirement, you modify it accordingly.

I am able to get the expected.

enter image description here