PowerShell removing console message colors when using tee-object PowerShell removing console message colors when using tee-object powershell powershell

PowerShell removing console message colors when using tee-object


Try this instead:

powershell.exe -noprofile -command { $path\test_main.ps1 | tee-object $log }

This happens because this part is executed first:

powershell.exe -noprofile -file $project_root/test_main.ps1 

Such that what tee-object sees is the output of a native EXE. And AFAICT, PowerShell doesn't output error records (or highlight) stderr output from a native EXE (unless you redirect the error stream e.g. 2>err.log.