Search code examples
azurepowershellazure-devopsdevops

Query all ADO pipelines that contain inline powershell tasks


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?


Solution

  • 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:

    1. 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.

    2. 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.

    3. 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.

      • For PowerShell task, the task id is "e213ff0f-5d5c-4791-802d-52ea3e7be1f1".
      • For Azure PowerShell task, the task id is "72a1931b-effb-4d2e-8fd8-f8472a07cb62".

      enter image description here