title: Pass Secret Variable from TFS Build to Powershell script
body: <p>I have added secret variable called Password in my build definition as shown in this image:</p>
  
  <p><img src="https://i.stack.imgur.com/Zxyeb.jpg" alt="TFS Build Variables"></p>
  
  <p>I want to pass the Password to the PowerShell script in one of my build steps as shown in this image:</p>
  
  <p><img src="https://i.stack.imgur.com/rBs65.jpg" alt="Build Step"></p>
  
  <p>My PowerShell script looks like this</p>
  
  <pre><code> Param
  (
      [Parameter(Mandatory=$true)]
      [string]$UserName,
      [Parameter(Mandatory=$true)]
      [string]$Password
  )
  
  $appPool = New-WebAppPool -Name "test"
  $appPool.processModel.userName = $userName
  $appPool.processModel.password = $password
  $appPool.processModel.identityType = "SpecificUser"
  $appPool | Set-Item
  </code></pre>
  
  <p>But it looks like the type of the Password is not a string. I tried <code>PSCredential</code> but didn't work. Can somebody help me? How do I pass the password from build step to the PowerShell script and the type of the secure variable? I can't read the environment variable directly because I am running the PowerShell script on a target machine. So only option is to pass Password to the script as input.</p>