The question seems kinda basic, but I have not been able to find it online. I am creating log files, and upon finding different things, I want it to be with color. Green is OK, red is bad. Just to make it faster to go through. However, whatever I seem to to do with Out-File, Add-Content or whatever I`m not able to get it going.
Anyone got a clue?
$stringRed = "This text should be red"
$stringGreen = "This text should be green"
$Logfile = "C:\text.txt"
Function LogWrite
{
Param ([string]$logstring)
$logstring | Out-File -FilePath $Logfile -Append
}
LogWrite $stringRed -ForegroundColor Red
LogWrite $stringGreen -ForegroundColor Green
#writes corretly to the console
Write-Host $stringRed -ForegroundColor Red
Write-Host $stringGreen -ForegroundColor Green