-
Azure DevOps PowerShell Scripts - List all release definitions
If you want to list all the Azure Pipelines Release Definitions for all projects in an Azure DevOps organisation, this script will return a list of their names, the date of the latest release and a link to view the definition within the web UI.
Note that Release definitions are part of the “classic” release pipelines. If you’re using YAML-based deployments then those will be viewable via the Pipelines script.
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://vsrm.dev.azure.com/$organisation/$project/_apis/release/definitions?api-version=6.1-preview.4&`$expand=lastRelease" -Method Get -Headers $headers $result.value | Select-Object name, @{ Name="CreatedOn"; Expression= { $_.lastRelease.createdOn }}, @{ Name = "Url"; Expression = { $_._links.web.href }} } | Sort-Object
It makes use of the Definitions - List REST API. Note that the documentation for that API is slightly misleading in the examples. You do need to pass in
$expand=lastRelease
to get thelastRelease
property populated. -
Azure DevOps PowerShell Scripts - List all Azure Pipelines
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. -
Azure DevOps PowerShell Scripts - List all Git repositories
If you want to list all the Git repositories for all projects in an Azure DevOps organisation, this script will return all the remote URLs.
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/git/repositories?api-version=6.0" -Method Get -Headers $headers $result.value.remoteUrl } | Sort-Object
It makes use of the Repositories - List REST API, so you could ask for any of the other properties instead of or in addition to
remoteUrl
as well.