StarWind is a hyperconverged (HCI) vendor with focus on Enterprise ROBO, SMB & Edge

Using PowerShell Tasks and Parameters in Azure DevOps Pipelines

  • December 17, 2020
  • 5 min read
IT Production Manager. Nicolas is primarily focused on Microsoft technologies, he is a Microsoft MVP in Cloud and Datacenter Management.
IT Production Manager. Nicolas is primarily focused on Microsoft technologies, he is a Microsoft MVP in Cloud and Datacenter Management.

Azure DevOps Services | Microsoft Azure

Azure DevOps is a powerful tool for any organization. Thanks to Azure DevOps you can perform a lot of admin tasks. For instance, you can quickly deploy applications to various Azure services such as Virtual Machines.

Sometimes, in the Release Pipelines, you might need to add PowerShell Tasks. In these PowerShell Tasks, you might also need to pass arguments to your script, so in this article, I will describe how to pass arguments in Release Azure DevOps PowerShell Tasks.

Deploying Azure DevOps Pipeline

First, we have to create a sample PowerShell script that will be stored in our Azure DevOps repository. This script will be used in the release task as “PowerShell Task”.

This script is a simple script that will create a Confluence space using Atlassian REST API, but you can create a script to perform any task you want.

Confluence space

The important thing to do is to include the following code at the beginning of your script:

Thanks to the CmdletBinding, you will be able to add [Parameter()] decorators to parameters (more information here:

At this step, you must confirm that your script runs smoothly locally. Then, you can create your pipeline and add the variables you need. Go to the Variables tab and click Add

Add the variables

In my case, I need to create 5 variables because I need to pass 5 arguments to the script. The name of the variables can be the same between your script and the pipeline but it is not mandatory. Now, go to “Tasks” and click “+”, then search “PowerShell” and click “Add

Add tasks

Browse the repository and select your PowerShell script. In the arguments field, add the following code:

  • “ScriptArg1” is the argument you write at the beginning of your script
  • “PipelineArg1” is the variable you create in the pipeline


Once it’s ok, you can save and create the release.

Create the release

Wait until the release has been created.

Release process

Click Deploy to run the task and confirm that the variables are passed to the script.

Deploy to run the task

To confirm the result, go to Logs and check the status.

Agent job / Check the status

Hey! Found Nicolas’s insights useful? Looking for a cost-effective, high-performance, and easy-to-use hyperconverged platform?
Taras Shved
Taras Shved StarWind HCI Appliance Product Manager
Look no further! StarWind HCI Appliance (HCA) is a plug-and-play solution that combines compute, storage, networking, and virtualization software into a single easy-to-use hyperconverged platform. It's designed to significantly trim your IT costs and save valuable time. Interested in learning more? Book your StarWind HCA demo now to see it in action!