This project is read-only.

How to access build variables in Powershell script

Jan 11, 2012 at 1:03 PM


Firstly, well done on an excellent tool. Its fantastic.

Could you provide a sample of how to access the build variables returned from TFS in a powershell script. I have not been able to access them so far.

A one liner would be fantastic just to point me in the right direction



Jan 11, 2012 at 9:23 PM

Hi Dave,

There are a handful of variables TFS injects into the PowerShell session the deployment script runs in. They are:

  • $TfsDeployerComputer
  • $TfsDeployerNewQuality
  • $TfsDeployerOriginalQuality
  • $TfsDeployerScript
  • $TfsDeployerBuildDetail

Most of these are strings except one, $TfsDeployerBuildDetail which is an object almost identical to the Microsoft.TeamFoundation.Build.Client.IBuildDetail class.

Here is a one-liner demonstrating use of this last variable:

Write-Output ("The build number is: " + $TfsDeployerBuildDetail.BuildNumber)



Jan 12, 2012 at 5:01 PM

Thanks, all working great now.