Member-only story
Unlock Pipeline Magic: My Methods To Use PowerShell In Azure DevOps
When you create a pipeline in Azure DevOps, did you know that it usually runs PowerShell code in many of its built-in tasks?
Indeed, PowerShell is the backbone of most tasks you get when you open up the editor when creating a pipeline (or Node as a runner task).
While you can create your own task in an extension, some tasks run PowerShell code directly.
Think of the most obvious ones:
- AzureCLI@2 — with script type to
ps
- AzurePowerShell@5
- PowerShell@2
Each of these tasks has its required input, either by using a script path directly, or an inline script.
Working with Azure DevOps for quite some time now (even before it was named that), I’ve come across different methods that might benefit you as well in using these tasks.
Each of these methods has its advantages and disadvantages on using them. Let’s look at some of the methods (you might use in the future?!).
Method One — The Script Path
This was definitely when starting out creating pipelines the first method I went by. Create a script, put it in your repository, and call it like the example below.