Azure DevOps PowerShell Scripts - List all Azure Pipelines

Written on June 10, 2021

Azure Pipelines logo If you want to list all the Azure Pipelines for all projects in an Azure DevOps organisation, this script will return a list of their names.

See Personal access tokens for instructions on how to create the personal access token.

param (
    [string] $organisation,
    [string] $personalAccessToken
)

$base64AuthInfo= [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($personalAccessToken)"))
$headers = @{Authorization=("Basic {0}" -f $base64AuthInfo)}

$result = Invoke-RestMethod -Uri "https://dev.azure.com/$organisation/_apis/projects?api-version=6.0" -Method Get -Headers $headers

$projectNames = $result.value.name

$projectNames | ForEach-Object {
    $project = $_

    $result = Invoke-RestMethod -Uri "https://dev.azure.com/$organisation/$project/_apis/pipelines?api-version=6.0-preview.1" -Method Get -Headers $headers

    $result.value.name
} | Sort-Object

It makes use of the Pipelines - List REST API, so you could ask for any of the other properties instead of or in addition to name as well.

Categories: Azure DevOps, Azure Pipelines, PowerShell