title: passing pipeline variable as argument into Powershell build step not working in Azure DevOps
body: <p>I want to be able to pass a pipeline variable into a Powershell build step in Azure DevOps Server. I'm trying to accomplish this by passing the variable as an argument.</p>
  <p>Here is my pipeline YAML file:</p>
  <pre><code>- task: PowerShell@2
    displayName: 'Detect Subfolder Changes'
    name: setvarStep
    inputs:
      targetType: 'filePath'
      filePath: $(System.DefaultWorkingDirectory)\detectchanges.ps1
      failOnStderr: true
    
  - task: PowerShell@2
    displayName: 'Get Version Number'
    name: getVersion
    inputs:
      arguments: &gt;
        - packagepath $(setvarStep.changedPackage)
      targetType: 'filePath'
      filePath: $(System.DefaultWorkingDirectory)\getversion.ps1
      failOnStderr: true
  </code></pre>
  <p>Here is the Powershell script (getversion.ps1) where I pass the 'packagepath' argument:</p>
  <pre><code>param($packagepath)
  
  Write-Host &quot;packagepath is: $packagepath&quot;
  
  $xml = [Xml] (Get-Content $packagepath)
  $version = [Version] $xml.Project.PropertyGroup.Version
  
  &quot;##vso[task.setvariable variable=packageVersion;isOutput=true]$version&quot;
  </code></pre>
  <p>The Writ-Host command prints out 'packagepath is: -'. I turned on debugging and the argument value does show up in the log as: <code>##[debug]INPUT_ARGUMENTS: '- packagepath dotnet/TestPackage/*.csproj'</code></p>
  <p>Instead of passing the variable as an argument I also tried inserting the variable into the script like this: <code>$packagepath = $($env:SETVARSTEP.CHANGEDPACKAGE)</code> but it didn't work.</p>
  <p>I did try adding double quotes to the argument parameter in the build step like this: <code>- packagepath &quot;$(setvarStep.changedPackage)&quot;</code>. It didn't work either.</p>
  <p>The argument value is getting to the Powershell script, getversion.ps1 but for some reason the value is not displaying.</p>