I am trying to return a color based on two boolean values. But, It keeps returning White or Gray. None of the red colors.
I have these two functions in a powershell script file:
function GetTextColor($shouldBeHighlighted, $shouldBeError){
if($shouldBeError -eq $true){
if($shouldBeHighlighted -eq $true){
return "Red"
} else {
return "DarkRed"
}
} else {
if($shouldBeHighlighted -eq $true){
return "White"
} else {
return "Gray"
}
}
}
function PrintColoredText($content, $isError){
if($line -match "abc") {
$color = GetTextColor($true, $isError)
Write-Host $line -ForegroundColor $color
} else {
$color = GetTextColor($false, $isError)
Write-Host $line -ForegroundColor $Color
}
}
I call the function with something like these:
PrintColoredText("some text", $true)
PrintColoredText("some text", $false)
What am I doing wrong?