This is a really basic fact, but it is often underestimated. PowerShell core is now available on Linux and this means that you can use PowerShell for your Azure DevOps pipeline even if the pipeline will be executed on Linux machine. If I have this task in a pipeline
I can schedule the pipeline on a Linux hosted agent, and everything runs smoothly.
As you can see from Figure 1 task output clearly states that the task can run PowerShell scripts on Windows, macOS or Linux. Sadly enough, most people still associate PowerShell with Windows and underestimate the fact that it runs perfectly on Linux.
The advantage of PowerShell is simple, it runs now on every system, if you write script in PowerShell it will run on any system, it is preinstalled in Windows and you can install in macOS or Linux with very little effort.
If you are using Azure Hosted Agent, PowerShell 7 is already preinstalled and it is already available for you to use.
If you need to know what software is installed on Hosted machine you can find the list at this link
If you are going to use your own Linux Agents, you need to manually install PowerShell on agent for task to run, but the net effect is the same: Writing task in PowerShell gives you a powerful language to automate your pipeline task in every system.