Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

How to use ForegroundColor with Read-Host in while loop?

$
0
0

I'm prompting for an optional action (amidst other output) like this:

$question = "Create Software Inventory Report? [y|n]"
$answer = ""
while ($answer -notmatch "[y|n]") {
      $answer = Read-Host $question -ForegroundColor Yellow
}

Is there any way to apply -ForegroundColor to $question text?

As it is now, I get monochrome output that looks like this:

Create Software Inventory Report? [y|n] -ForegroundColor Yellow:



Viewing all articles
Browse latest Browse all 21975

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>