TeamCity
 
You are viewing the documentation for an earlier version of TeamCity.

PowerShell

Last modified: 20 April 2023

PowerShell build runner is designed specifically to run PowerShell scripts.

PowerShell Settings



Interaction with TeamCity



Attention must be paid, when using PowerShell to interact with TeamCity through service messages. Powershell tends to wrap strings written to console with commands like Write-Output, Write-Error and similar (see TW-15080). To avoid this behavior, either Write-Host command should be used, or buffer length should be adjusted manually:

function Set-PSConsole { if (Test-Path env:TEAMCITY_VERSION) { try { $rawUI = (Get-Host).UI.RawUI $m = $rawUI.MaxPhysicalWindowSize.Width $rawUI.BufferSize = New-Object Management.Automation.Host.Size ([Math]::max($m, 500), $rawUI.BufferSize.Height) $rawUI.WindowSize = New-Object Management.Automation.Host.Size ($m, $rawUI.WindowSize.Height) } catch {} } }

Development Links



PowerShell support is implemented as an open-source plugin. For development links refer to the PowerShell.