Creating a New Release Iteration (with Sprints!) Using Powershell

“Always choose a lazy person to do a difficult job because a lazy person will find an easy way to do it.”

Frank B. Gilbreth Sr. , paraphrased

If you’ve stumbled upon this article, you’re probably searching for a quick and easy way to bulk create iterations in Azure DevOps. You’re probably also thinking, “Hey, DevOps has an API. I’m sure I can do it through there.” You may have even stumbled upon Donovan Brown’s article. If you did, you probably ran into the same problem I did; there are (currently) no API calls for admin functions such as adding iterations to a project.

“…sorry for the confusion, this api is not meant to create a iteration, but to subscribe an existing iteration to your team…”

Once they are added to the project, you can assign them to a team via the API, but first you have to go through the tedious process of Add Child > Name, Start Date, Finish Date.

Not content with this, I decided to take a peek at what was happening under the covers when I created a new iteration. Firing up Fiddler and creating a new iteration, I found this magic:

https://[myTenant][GUID]/_admin/_Areas/CreateClassificationNode?useApiUrl=true&__v=5 HTTP/1.1

{"operationData":"{\"NodeId\":\"00000000-0000-0000-0000-000000000000\",\"NodeName\":\"Iteration 001\",\"ParentId\":\"[PARENT GUID]\",\"IterationStartDate\":\"\\/Date(1578268800000)\\/\",\"IterationEndDate\":\"\\/Date(1579392000000)\\/\"}","syncWorkItemTracking":false}

Using this as a base, I created the following Powershell script.

Warning: This is not a supported Microsoft API and can change at any time.

First, grab the code from GitHub.

Second, you will need a user token. As a user with rights to create iterations in a project, go to Azure DevOps > User Settings > Personal Access Tokens, and create a new token titled something like “Iteration PowerShell”. Set the expiration to whatever length you’re comfortable with.

Next, you’ll need your Azure DevOps project’s GUID. From a web browser, go to:[YOUR_TENANT]/_apis/projects?api-version=5.1

This will return a list of your projects. Find the appropriate project and copy the project id.

Finally, you’ll need the GUID of the root project iteration. This is a little more complicated as it’s not readily available via the API (see previous complaint about lack of admin API calls). To get the GUID, fire up Fiddler and start capturing. Go to your Azure DevOps project configuration settings and edit the root item (you can immediately cancel the edit). Now, in Fiddler results, find the URL “/_apis/Contribution/dataProviders/query”. In the JSON, you will find the property “nodeId”. This is your root iteration GUID.

That’s it. Enter the token and project ID in the Powershell, set the other values as appropriate, and run it.

$projectId = "PROJECT GUID"

2 thoughts on “Creating a New Release Iteration (with Sprints!) Using Powershell

  1. When you say “edit root item” on project configuration settings page. Can you please help us through a screenshot.I am not sure what exactly needs to be done.
    Thanks a Lot in Adv.!

Leave a Reply

Your email address will not be published. Required fields are marked *

6 + ten =