Wednesday, December 20, 2017

Microsoft TFS Build and Release Notes - Write-Host errors in PS Script

When developing out TFS 2015/2107 build and release definitions, it is good to log your steps when you queue out a build or release.  I write out to the logs when I'm using any of the PowerShell tasks ('Run a PowerShell script' or 'Execute PowerShell scripts on remote machine(s)', for example) in a build or release.


There is, however, a good and bad way to log in a PowerShell script in VSTFS 2015/2017.


In your PowerShell tasks, do NOT use Write-Host, as this will fail when you try to run a Build or Release. 

Instead, use Write-Verbose in the PS script and you will get the results you need.