Forum Discussion
balubeto
Nov 17, 2022Brass Contributor
For loop and counter
Hi I tried to write this script: For ($Counter = 0; $Counter -le 15; $Counter++)
{
Write-Host $Counter -ForegroundColor $Counter
} How come the Write-Host command also accepts a numeric o...
Alan2022
Nov 18, 2022Iron Contributor
balubeto
Hi,
The Write-Host cmdlet's primary purpose is to produce for-(host)-display-only output, such as printing colored text like when prompting the user for input in conjunction with Read-Host. Write-Host uses the ToString() method to write the output. By contrast, to output data to the pipeline, use Write-Output or implicit output.
https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/write-host?view=powershell-7.3