title: Powershell - Overiding Arguments Relase definition
body: <p>I am trying to create a Release definition in TFS 2017 with powershell script</p>
  
  <p>I am runing a powershell script that has to find a path of a setParameters.xml file which it does and it suppose to over ride all the tokens but the it just ignores the loop and the arguments stay the same.</p>
  
  <p>Script code:</p>
  
  <pre><code>$vars = Get-ChildItem -path env:*
  
  # read in the setParameters file
  $contents = Get-Content -Path $paramsFilePath
  
  # perform a regex replacement
  
  $newContents = "";
  $contents | % {
      $line = $_
      if ($_ -match "__(\w+)__") {
          $setting = Get-ChildItem -path env:* | ? { $_.Name -eq $Matches[1]  }
          if ($setting) {
              Write-Verbose -Verbose ("Replacing key {0} with value from environment" -f $setting.Name)
              $line = $_ -replace "__(\w+)__", $setting.Value
          }
      }
      $newContents += $line + [Environment]::NewLine
  }
  </code></pre>
  
  <p>Why is the loop being skiped and how could i fix it so it overwrites the arguments in SetParameters.xml file?</p>