Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Add conditional colorization to Format-Table command #3886

Closed
pcgeek86 opened this issue May 30, 2017 · 7 comments
Closed
Labels
Issue-Enhancement the issue is more of a feature request than a bug Resolution-No Activity Issue has had no activity for 6 months or more WG-Engine core PowerShell engine, interpreter, and runtime

Comments

@pcgeek86
Copy link

The Format-Table command in PowerShell displays objects in a fundamentally similar manner as Microsoft Excel spreadsheets. Microsoft Excel provides a conditional formatting feature that enables spreadsheet builders to change the display format of a cell, based on the value of the cell's contents.

It would be really great if a PowerShell user could add conditional formatting rules to object properties, using the Format-Table command. That way, let's say you have an object with a Status property. That property could be emitted as Green if its value is Success or Red if the property value is Failed.

Name   Status
----   ------
Step 1 Failed (Red)
Step 2 Success (Green)

For example, you could add a custom property specifier in the Format-Table command as follows:

Get-SomeObjects | Format-Table -Property Name, @{ Name = 'Status'; Color = 'Green'; Value = '^Success$' }

In PowerShell today, we already have a similar syntax for building "calculated properties." We could leverage a similar syntax to build colorized expressions in data tables. This capability would be useful to build PowerShell-based dashboards and presenting data in a more useful manner in the console.

Cheers,
Trevor Sullivan

@joeyaiello joeyaiello added WG-Engine core PowerShell engine, interpreter, and runtime Issue-Enhancement the issue is more of a feature request than a bug labels May 30, 2017
@joeyaiello
Copy link
Contributor

Definitely a future enhancement, but I agree this would be awesome.

@rkeithhill
Copy link
Collaborator

Ditto for Format-Custom, Format-List and Format-Wide

@JohnLBevan
Copy link
Contributor

For anyone wanting this today, Ahmad Adel Gad has offered a solution, Write-PSObject, on TechNet's Script Center. https://gallery.technet.microsoft.com/scriptcenter/Format-Table-Colors-in-e0a4beac

For conditional formatting, see example 16B.01: Write-PSObject $servers -MatchMethod Exact -Column * -Value $false -ValueForeColor Red;

There's some really good thought into the options available on this CmdLet, so could be a good source of inspiration for this enhancement request too.

Copy link
Contributor

This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

1 similar comment
Copy link
Contributor

This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

@microsoft-github-policy-service microsoft-github-policy-service bot added Resolution-No Activity Issue has had no activity for 6 months or more labels Nov 16, 2023
Copy link
Contributor

This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

Copy link
Contributor

This issue has been marked as "No Activity" as there has been no activity for 6 months. It has been closed for housekeeping purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Enhancement the issue is more of a feature request than a bug Resolution-No Activity Issue has had no activity for 6 months or more WG-Engine core PowerShell engine, interpreter, and runtime
Projects
None yet
Development

No branches or pull requests

4 participants