I have some console outputs which also are logged in a txt file.
Write-Host "$Time : $file failed/skipped. Technical information: $ExceptionMessage" | Out-file -FilePath $logPath -Append
Now I want that this message appears in red on the cmd console. So I tried this with -ForegroundColor but it did not work out:
Write-Host "$Time : $file failed/skipped. Technical information: $ExceptionMessage" -ForegroundColor Red | Out-file -FilePath $logPath -Append
It seems like Out-File das not like the -ForegroundColor property.
Is there a way to log console output which is also colored?