If you need to know the branch that you are running your build against, you can use Build.SourceBranchName Environment variable.
As described here: https://msdn.microsoft.com/en-us/library/vs/alm/build/scripts/variables
The name of the branch the build was queued for.
- For Git this is the last path segment in the ref. For example in
refs/heads/master
the name ismaster
. - For TFVC this will last path segment in the root server path for the workspace. For example in
$/teamproject/branch
the name isbranch
You can access the variable from PowerShell this way:
Write-Host “Branch: $Env:BUILD_SOURCEBRANCHNAME”