-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Description
Hi,
So I tried to use your Write-Host function in remote sessions and it didn't output any text. That is due to the usage of System.Console.Write(Line) which are not usable in remote sessions. See the issue I opened on the Powershell repo about this:
So, I would suggest that you make the same change I did in order to make this work:
@@ -83,8 +83,6 @@ function Write-Host {
Process {
# https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_special_characters#escape-e
# https://docs.microsoft.com/en-us/powershell/scripting/windows-powershell/wmf/whats-new/console-improvements#vt100-support
- if ($Host.UI.SupportsVirtualTerminal) {
- $Method = if ($NoNewline) { 'Write' } else { 'WriteLine' }
$Output = if ($Separator) { $Object -join $Separator } else { "$Object" }
# Splitting by regex ensures that this will work on files from Windows/Linux/macOS
@@ -97,11 +95,7 @@ function Write-Host {
$item = $AnsiTemplate -f $AnsiColor[$ForegroundColor.value__], $item, 39
}
- [System.Console]::$Method($item)
- }
- }
- else {
- Microsoft.PowerShell.Utility\Write-Host @PSBoundParameters
+ if ($NoNewLine) { Microsoft.PowerShell.Utility\Write-Host -NoNewLine $item } else { Microsoft.PowerShell.Utility\Write-Host $item }
}
}
}
So, instead of using System.Console.Write or System.Console.WriteLine, simply use the default Write-Host function. Therefore, it makes calls inside remote sessions output colored text in Azure DevOps pipeline just as calls outside of remote session.
Metadata
Metadata
Assignees
Labels
No labels