title: How to get current Build definition name using PowerShell in TFS
body: <p>We are using TFSdeployer to trigger Build deployment to deploy build.</p>
  
  <p>But stuck with how to get Build definition of the current Build for which we trying and could not succeed.</p>
  
  <p>How to get current Build definition name using below PowerShell script instead of hardcode. </p>
  
  <p>Scenario: If i trigger from Test1 BuildQuality then first code should be working . If i trigger from Test2 BuildQuality then second code should be working. (If-Else code is working perfectly)</p>
  
  <p>Tried using $TFSDeployerBuildDetail.DefinitionName
  $Build.Name</p>
  
  <p>But that seems to be not working, Any help is appreciated.</p>
  
  <pre><code>$BuildDefinitionName =  "Test1"
  $PackagePath = "C:\extra\Package_Files"
  $DestPath1 ="C:\extra\Test1"
  $DestPath2 ="C:\extra\Test2"
  $logFile ="C:\extra\logs"
  $utilPath = "C:\util\"
  
  
  if ($BuildDefinitionName -eq "Test1")
  {
  
  Write-Host "Testing 1st Copy"
  
  Add-Content -Path $logFile "Copying to Test1"
  &amp; $utilPath\robocopy $PackagePath $DestPath1 /s &gt;&gt; $logFile
  
  }
  
  elseif($BuildDefinitionName -eq "Test2")
  {
  
  Write-Host "Testing 2nd Copy"
  Add-Content -Path $logFile "Copying to Test2"
  &amp; $utilPath\robocopy $PackagePath $DestPath2 /s &gt;&gt; $logFile
  
  }
  </code></pre>