SharePoint, Office 365, Azure, and Front end JS geek. – Chicago IL
SharePoint, Office 365, Azure, and Front end JS geek. – Chicago IL

Colorize PowerShell Transcript with CSS

I use Start-Transcript and Stop-Transcript on nearly all PS1 files I create.   It’s a great way to troubleshoot and easily make detailed log files.   PowerShell gives us Write-Host -ForegroundColor to make console output look snazzy with color.   However, TXT output is flat by comparison without color coding.

Below I have sample code for adding <STYLE> and <DIV> tags to PowerShell Write-Host.  This example uses Get-Process to highlight any process using more than 50MB RAM in yellow and 500MB RAM in red.

After renaming TXT to HTM, we can see with Internet Explorer highlights from Transcript logs after the script runs.  Cool beans!  Please leave a comment if you found this helpful.  

shades_smile

 

Code

 

 

Screenshots

image
color

© Copyright 2016
@ SPJeff

Return to Top ▲Return to Top ▲