I'm wondering if it's possible to write some coloured-text in orange with Write-Host
(or with another PowerShell Cmdlet).
It seems Orange
is not an available color for the -ForegroundColor
parameter, but commands like Write-Warning
are able to display something in orange.
Write-Host sends the objects to the host. It does not return any objects. However, the host displays the objects that Write-Host sends to it.
The PowerShell Write-Host cmdlet is used to write the customized output to a host. We can specify the text color by using the -foreground parameter, and by using the -background parameter, we can specify the background color.
Found what appears to be Write-Host code here: Powershell-Misc/Write-Host.ps1 at master · beatcracker/Powershell-Misc · GitHub
Found ANSI escape codes here: ANSI escape code - Wikipedia
Found color orange here: RGB Color Codes Chart
Built this code based on info taken from the above:
$Esc = [char]27
$Ansi24BitTemplate = "$Esc[{0};2;{1};{2};{3}m"
$Ansi24BitFore = '38'
$Ansi24BitBack = '48'
$OrangeForeColor = $Ansi24BitTemplate -f $Ansi24BitFore, 255, 165, 0
$OrangeBackColor = $Ansi24BitTemplate -f $Ansi24BitBack, 255, 165, 0
Write-Host "$($OrangeBackColor)Testing" -ForegroundColor Black
Write-Host "$($OrangeForeColor)Testing" -BackgroundColor Black
Which gave this output:
NOTE: This will not work on some older equipment and in some situations. But I believe it will work in the majority of Windows 10 computer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With