Ayan Mullick
Ayan Mullick

Reputation: 162

Retain coloring scheme for Powershell cmdlet after execution

Is there any way to retain the Powershell command coloring scheme after execution of the command in the Console Pane.

enter image description here

And is there a way to color the output column-headers separately.

None of the themes I browsed or could find online achieve this.

Upvotes: 0

Views: 191

Answers (2)

Ayan Mullick
Ayan Mullick

Reputation: 162

The Output Colorizer VSC extension does it for the Output stream. I wish it could colorize the terminal output too. https://marketplace.visualstudio.com/items?itemName=IBM.output-colorizer

@uruloki

Upvotes: 0

uruloki
uruloki

Reputation: 23

Try the following:

Get-Disk | Select -property * | ft -AutoSize -Wrap | Out-String -stream | %{if($_ | Select-String 'Style' -NotMatch){Write-Host $_ -f Yellow}else{Write-Host $_}}

This passes your output to a string. The -stream operator makes each line into a separate string, and you then check each string for something in your header ('Style'). If it checks, the string gets written out with the color formatting.

Upvotes: 1

Related Questions