PowerShell
PowerShell build runner is designed specifically to run PowerShell scripts.
PowerShell Settings
Option | Description |
---|---|
Version | List of PowerShell versions, supported by TeamCity. Since 8.1 is passed to |
Powershell run mode | Select the desired execution mode on a x64 machine. |
Error Output | Specify, how error output is handled by the runner:
|
Working directory | Specify the path to the Build Working Directory. |
Script | Select whether you want to enter the script right in TeamCity, or specify path to a script:
|
Script execution mode | Specify the PowerShell script execution mode. By default, Powershell may not allow execution of arbitrary |
Script arguments | Available if "Script execution mode" option is set to "Execute .ps1 script with the |
Additional command line parameters | Specify parameters to be passed to |
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.