
Now if you want to set John to be a certain colour then you can use the code below.
Note for static values this doesn’t add much value, we use it for a table that is getting printed dynamically e.g. based on a timer tick and dynamic version of the Name

This requires PowerShell 5.1 or later (check with $PSVersionTable.PSVersion
) and doesn’t seem to play fair with the PowerShell ISE, however from a normal PowerShell window or VSCode it works a charm.
Happy colouring!
Original article was posted on Boro2g Blog: Setting a row colour in powershell