How can I pass a parameter to a PowerShell-Inline-Task? Or how can I access the parameter in a PowerShell-Inline-Task? I know that there is the "$env"-Variable, and that I can read variables, but how is this done with parameters?
Tested from my side, I use parameters in PowerShell-Inline-Task as the following. The name of the parameter is "paratest", the type is string, the default value of it is one and also it has another value "two".
I get and output the value of the parameter in the PowerShell task using ${{ }}.
parameters:
- name: paratest
type: string
default: one
values:
- one
- two
trigger:
- none
pool:
vmImage: ubuntu-latest
steps:
- task: PowerShell@2
inputs:
targetType: 'inline'
script: 'Write-Host "The value of parameter paratest is ${{parameters.paratest}}"'
Before I run the pipeline, I can choose the value of the parameter "paratest".

Then I can see the value of this parameter in the PowerShell task.

For more info about parameters, you can refer to Runtime parameters.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With