Skip to content

OCGV : Display only some properties but still pass the full object to the pipelineΒ #261

@Nacos

Description

@Nacos

Summary of the new feature / enhancement

I would like to be able to control what properties are displayed in Out-ConsoleGridView but still be able to get all object properties passed on the pipeline for further processing.

As far as I know, the only way to control what is displayed using ocgv is to use Select-Object to filter what properties to display.

Example :

Get-Process `
 | Select-Object -Property Name, Id `
 | Out-ConsoleGridView -Title 'Select processes to inspect' -OutputMode Multiple `
 | Foreach-Object {
    Write-Host ('--- [{0}] ---' -f $_.Name)
    Write-Host ('ID: {0}' -f $_.Id)
    Write-Host ('Command line : {0}' -f $_.CommandLine)
    Write-Host ('Working Set : {0}' -f $_.WorkingSet)
}

Output :

--- [Code] ---
ID : 34388
Command line :
Working Set :
--- [msedge] ---
ID : 22992
Command line :
Working Set : 

However, as shown in my example, currently CommandLine and WorkingSet will not show anything as these properties are not passed down the pipeline.

Proposed technical implementation details (optional)

I would like to get a new parameter for Out-ConsoleGridView cmdlet.
Something like -DisplayProperties that could take a list of properties to display.

This way, we could remove the filter Select-Object and retains the full object down the pipeline for further processing.

Example :

Get-Process `
 | Out-ConsoleGridView -Title 'Select processes to inspect' -OutputMode Multiple -DisplayProperties Name,Id `
 | Foreach-Object {
    Write-Host ('--- [{0}] ---' -f $_.Name)
    Write-Host ('ID: {0}' -f $_.Id)
    Write-Host ('Command line : {0}' -f $_.CommandLine)
    Write-Host ('Working Set : {0}' -f $_.WorkingSet)
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions