Skip to content

Instantly share code, notes, and snippets.

@rfennell
rfennell / export-svntip2git.ps1
Created June 27, 2025 10:55
Exports branches from SVN and creates a Git repo (no history)
param
(
$localrepopath = "c:\svn\localrepo",
$trunkurl = "svn://svnlive.mydomain/application/trunk",
[string[]]$branches = @(
"svn://svnlive.mydomain/application/releases/1.0.0",
"svn://svnlive.mydomain/application/releases/2.0.0"
)
)
@rfennell
rfennell / workflow-rev-sample.yml
Last active June 17, 2025 14:45
A sample GitHub Actions Workflow that provides the same behaviour as the Azure DevOps Pipeline $(rev:r) build name i,e, counts the runs of a named build on the current date
name: Workflow Rev Sample
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
# You have to grant the actions read permission else the GH CLI get a 403 error
permissions:
@rfennell
rfennell / Generate-AzdoInheritedProcessUpdateCommands.ps1
Created June 5, 2025 13:26
A PowerShell script to generate SQL commands to update inherited process template WITD display names based on error in an Azure DevOps Migration error log
param (
$logfile = "DataMigrationTool.log",
$tpcUrl = "http://server:8080/tfs/defaultcollectio",
$outputFile = "update-fields.sql"
)
$Errors = @{}
function Get-ItemFromRow {
param (
$row,
$startString,
@rfennell
rfennell / Generate-AzdoXmlProcessUpdateCommands.ps1
Created June 5, 2025 12:45
A PowerShell script to generate WITAdmin commands to update XML process template WITD display names based on error in an Azure DevOps Migration error log
aram (
$logfile = "DataMigrationTool.log",
$tpcUrl = "http://server:8080/tfs/defaultcollection",
$witAdminPath = "C:\Program Files\Microsoft Visual Studio\2022\Professional\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\witadmin.exe",
$outputFile = "update-fields.ps1"
)
$Errors = @{}
function Get-ItemFromRow {
param (
$row,
@rfennell
rfennell / export-ado-testsuite.py
Last active May 28, 2025 16:29
A Python script to export all Azure DevOps Test Suites in a Team Project as Excel files (replicated the Azure DevOps UI Export button)
import requests
import base64
import os
import argparse
def download_testcases_excel(organization, project, pat, test_case_ids, test_plan_id, test_suite_id, output_path):
"""
Download test cases as an Excel file from Azure DevOps Test Plan API.
"""
api_url = f"https://dev.azure.com/{organization}/{project}/_apis/testplan/TestCases/TestCaseFile?api-version=7.1-preview.1"
@rfennell
rfennell / Get-AZDOPipelineDetailsForAllProjects.ps1
Last active May 16, 2025 13:53
This script connects to an Azure DevOps organization using a Personal Access Token (PAT). It enumerates all projects within the organization, retrieves all pipelines for each project, and gathers details about each pipeline, including type (YAML or Classic), source repository, default branch, repository URL, and the status and time of the latest…
<#
.SYNOPSIS
Retrieves pipeline information for all projects in an Azure DevOps organization and exports it to a CSV file.
.DESCRIPTION
This script connects to an Azure DevOps organization using a Personal Access Token (PAT).
It enumerates all projects within the organization, retrieves all pipelines for each project,
and gathers details about each pipeline, including type (YAML or Classic), source repository,
default branch, repository URL, and the status and time of the latest run.
The collected information is exported to a specified CSV file.
.PARAMETER organization
@rfennell
rfennell / Get-AZDOPipelineDetailsForProject.ps1
Last active May 16, 2025 13:41
This script connects to an Azure DevOps organization and project using a Personal Access Token (PAT). It fetches all pipelines, gathers details about each pipeline (including type, source repository, branch, and latest run status), and exports the collected information to a CSV file.
<#
.SYNOPSIS
Retrieves Azure DevOps pipeline information and exports it to a CSV file.
.DESCRIPTION
This script connects to an Azure DevOps organization and project using a Personal Access Token (PAT).
It fetches all pipelines, gathers details about each pipeline (including type, source repository, branch, and latest run status),
and exports the collected information to a CSV file.
.PARAMETER organization
@rfennell
rfennell / Update-WorkitemField.yml
Last active February 7, 2025 11:19
A sample Azure DevOps YAML Pipeline to update WI based on a WIQL query
# A pipeline to update a specific field in a work items that meeting a specific WIQL filter
# Do not trigger on a commit to the repo, but allow a manual run
trigger: none
# Run the pipeline at 1am every day
schedules:
- cron: '1 0 * * *'
displayName: Daily midnight build
always: true
@rfennell
rfennell / Update-WorkitemField.ps1
Created January 30, 2025 11:13
A PowerShell script that used the Azure DevOps CLI to increment a Work Item field based on a WIQL query
[CmdletBinding()]
param (
[Parameter(Mandatory=$true, HelpMessage="The URL of the Azure DevOps organisation e.g. https://dev.azure.com/myorg")]
$org,
[Parameter(Mandatory=$true, HelpMessage="The name of the project e.g 'My Project' ")]
$project,
[Parameter(Mandatory=$false, HelpMessage="The name of the field to update, defaults to 'Custom.PBIAge'")]
$fieldName = "Custom.PBIAge",
[Parameter(Mandatory=$false, HelpMessage="The WIQL query to find the work items to update. This is used if --sharedWiQueryId is not specified")]
$query = "SELECT [System.Id] FROM workitems WHERE ([System.WorkItemType] = 'Bug' OR [System.WorkItemType] = 'Product Backlog Item' ) AND [System.State] IN ('Active', 'Committed')",
@rfennell
rfennell / agent-scheduled-job-yml
Last active August 30, 2024 09:12
Azure DevOps Custom Maintenance Jobs
# This is the pipeline that runs any scheduled maintainance jobs
# we wish to run in addition to the built in Azure DevOps Maintainance jobs
# The parameters to target each pool and agent
parameters:
- name: pool
- name: agent
- name: nvdapikey
# We cannot use to the parameters directly else we get a 'A template expression is not allowed in this context'