Reset Iteration Dates before you Demo

Dave Lloyd
2 min readMar 2, 2020

This one is for all of you out there that evangelize, teach or just find yourselves demoing Azure DevOps to others.

It’s easy to set up a demo project in Azure DevOps. In case you didn’t know already, there is a tool you can use called the Azure DevOps Demo Generator that will create a project in your organization with pre-populated sample content including source code, work items, iterations, build and release definitions. You can read all about it here.

I used this tool a long time ago to create a project for all my demos. The issue with this is that the iteration dates get old. When you first create the project there is a current iteration. The next time I want to do a demo the iterations are all in the past. :(

Azure cli azure-devops extension to the rescue. (To understand how to install the azure-devops extension of azure cli read my last article, Azure CLI azure-devops extension).

This time we’ll use the az boards command in the azure-devops extension.

The script below will reset your sprint dates so you have 1 past sprint a current sprint and 6 future sprints. If you want to use it “as is” make sure you have 8 iterations defined named Sprint 1, Sprint 2 etc...

When you run the script below it will find the last Monday, then go back 2 weeks and reset iteration 1 to that date. Then every other sprint from 2 thru 8 will be updated to two week iterations starting every other Monday after that.

Before running the script change the following variables to map to your Azure DevOps instance.

  • $org
  • $env:AZURE_DEVOPS_EXT_PAT
  • $projectName
  • $sprints
$org = 'https://dev.azure.com/YourOrg/'
$env:AZURE_DEVOPS_EXT_PAT='YourPersonalAccessTokenGoesHere'
echo $env:AZURE_DEVOPS_EXT_PAT | az devops login --org $org
$projectName = "Parts Unlimited"
$sprints = "\Parts Unlimited\Iteration\Sprint"
$lastMonday = (Get-Date).AddDays((-1 * (Get-Date).DayOfWeek.Value__) + 1).Date
write-host "Last Monday - $lastMonday"
$startDate = $lastMonday.AddDays(-14)
$finishDate = $startDate.AddDays(11)
For ($i=1; $i -le 8; $i++) {
Write-host "Sprint $i"
write-host "Start - $startDate"
write-host "Finish - $finishDate"
az boards iteration project update --path "$sprints $i",
--finish-date $finishDate,
--org $org,
--project $projectName,
--start-date $startDate
$startDate = $startDate.AddDays(14)
$finishDate = $startDate.AddDays(11)
}

I hope someone out there finds this useful.

--

--

Dave Lloyd

I have been writing software and teaching/coaching developers for 40 years. I love sharing knowledge and experience.