I need to query all pipielines and releases in our Azure DevOps organization / projects and return all pipelines that contain inline powershell tasks.
This task aims to remediate Microsoft's end of support for Azure RM module.
Do you know if this can be done by either az devops CLI or API?
There is not an easy way to query all the pipelines that contains inline PowerShell task within a project in Azure DevOps.
To use Azure DevOps related interfaces (CLI or REST API), you need to do like as below:
you can use below interfaces to list the pipeline definitions within a project. From the output (json), you can use a loop to get the ID of each pipeline definition.
For classic build pipelines and YAML pipelines: "az pipelines build definition list" (CLI) or "Build - Definitions - List" (REST API).
For classic release pipelines: "az pipelines release definition list" (CLI) or "Release - Definitions - List" (REST API).
For each pipeline definition, you can use below interfaces to get the details of definition (json). From the details, you can see the stages, jobs and steps (tasks) defined in the pipeline. You need to use loops to view each stage, each job and each step to check if the pipeline contains inline PowerShell task.
For classic build pipelines and YAML pipelines: "az pipelines build definition show" (CLI) or "Build - Definitions - Get" (REST API).
For classic release pipelines: "az pipelines release definition show" (CLI) or "Release - Definitions - Get" (REST API).
In the details of definition, you can use the task ID to identify the PowerShell task, and use "targetType
" or "ScriptType
" to identify the inline type.
e213ff0f-5d5c-4791-802d-52ea3e7be1f1
".72a1931b-effb-4d2e-8fd8-f8472a07cb62
".