Automation

 View Only
  • 1.  Change the color of the output on the console

    Posted Oct 18, 2020 05:42 PM

    I'm using a fubction to get output to file and I'm trying to find a way to have the output on the console colored, is that possible?



  • 2.  RE: Change the color of the output on the console

    Posted Oct 18, 2020 11:05 PM

    It depends a bit how the output on the console is created.

    Is that with Write-Host, then you can use the Foreground and Background parameters.

    If you are talking about error, warning, verbose, debug ... messages, you can change the values in the corresponding properties in $host.PrivateData.



  • 3.  RE: Change the color of the output on the console

    Posted Oct 19, 2020 07:34 AM

    Thanks LucD :smileyhappy:

    I'm using a function to log output to file , so if I have understood correctly shall I add this parametre $host.PrivateData to my function or I need to create another one?

    is there some samples to check and learn from it?:smileyblush:



  • 4.  RE: Change the color of the output on the console

    Posted Oct 19, 2020 08:58 AM

    Like it said earlier, it depends on how that output in that function is generated.

    Is that via Write-Host?

    If it is the colours of the standard messages (error, warning ...), you can use the $host.PrivateData properties.

    See for example Change the PowerShell Colors

    It would help if you show the code that generates the output.