Create Azure DevOps iterations using PowerShell

I start planning for the following year in the last two weeks of December. I use Azure DevOps to track my work  -break down goals into features, and features into user stories, which I map into sprints. Creating iterations and adding them to projects is something that anyone can automate. I learned that from Vinicius Moura’s blog -How to: Create all iterations to your project on Azure DevOps.
Using that approach, I created a year’s worth of iterations and added them to my project. In this note, I document my changes for my specific requirement.

Update Dec 2022: I automated this process using Azure DevOps. You may read about that at automate-iterations-in-Azure-Board-using-Azure-pipelines.

Pre-requisite: It is necessary to have an Azure DevOps organization, a project to host the iterations, and admin credentials of the project to generate PAT.
Note: I ran this script from my local laptop and did not attempt to create an Azure DevOps pipeline for that since I had to do it only once.
I classified this use case into five steps:
Step 1: Install Azure DevOps CLI
Step 2: Create Azure DevOps PAT
Step 3: Identify the start date, number of days in each iteration, and number of iterations to create and add to the team
Step 4: Create and add iterations to the team
Step 5: Review iteration and revoke PAT
I stored the PowerShell script in my GitHub repo: add-iterations-to-azure-devops-project.

Step 1: Install Azure DevOps CLI
The details on the installation are available at azure-devops-cli-extension.

Step 2: Create Azure DevOps PAT
Please check the following note on creating a PAT. I selected Read & write for the Work Items under the Scope of the PAT.
60-image-2
I copied the PAT value and stored it securely because that won’t be accessible later.

Step 3: Identify the start date, number of days in each iteration, and number of iterations to create and add to the team
I use Azure DevOps regularly, and the last sprint of 2021 ends on the 7th of Jan, 2022. Hence, the start date of the first sprint in 2022 is the 8th of Jan 2022. I use a two-week sprint cadence; thus, the last date of the sprint is $StartDateIteration.AddDays(13), which adds 13 more days to the start date of the sprint. Moreover, since I need iterations for the whole year, I selected the number of iterations as 26 (52 weeks in a year and 2-week sprints).

Step 4: Create and add iterations to the project
I like arranging the iterations such that it is easily accessible. Hence I added the --path $RootPath flag to the az boards iteration project create command. The $RootPath value is the year, which is 2022 for the current use case.
After creating the iterations, I added them to the project team. Here is an image of the first three iterations.

60-image-3
Step 5: Review iteration and revoke PAT
I triggered the PowerShell script, and it created the iterations and added them to the team project. I quickly reviewed and found that the iterations were created correctly and added to the team. Since my use case was complete, I revoked the PAT. Here is the MS Docs article on how to revoke PAT.

Last year, it took me over an hour to create the iterations and add them to the project, and I did not enjoy the process. This year, it took me the same time to understand the code, make tweaks to address my specific requirement, and run the code to auto-create the iterations and add them to the project team. However, I enjoyed the process this time, and from next year onwards, this automation should save me time.

If you manually manage iterations in Azure DevOps, I recommend you look into this automated process. I’ve tried to be descriptive in this note, and if you have questions, please use the comments section to ask.

One thought on “Create Azure DevOps iterations using PowerShell

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s