brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: Out-GridView -PassThru lets you pick rows in a window and pipe them on

CLI
~/tips/tip-windows-out-gridview-passthru

Get-Process | Out-GridView -PassThru | Stop-Process

Opens command output in a filterable window and passes the rows you select onward.

PowerShell output in a terminal is fine until it’s three hundred lines long. Out-GridView sends it to a separate window with a sortable, filterable table instead. What makes it really useful is that you can click rows and send just those down the pipeline.

Here’s my favourite example, picking processes to stop by clicking them:

Get-Process | Out-GridView -PassThru | Stop-Process

A window opens with every process. Type in the filter box at the top, sort by a column, then select one or more rows with Ctrl-click or Shift-click and press OK. Only those processes reach Stop-Process. Cancel the window and nothing happens, which makes it a nice safety step compared to typing names by hand.

Without -PassThru the cmdlet just shows the table and returns nothing, which is still great for browsing. If you want exactly one row back, use -OutputMode Single; -PassThru is the same as -OutputMode Multiple. Add -Title "Pick a process" to label the window, and ogv is the built-in alias if you’re lazy like me.

The caveats are about where it runs. It needs a desktop: it only works on Windows, and not on Server Core or Nano Server. It was left out of early PowerShell Core releases and came back in PowerShell 7, still Windows-only. You can’t open the window on a remote machine through a remote command, and output that already went through Format-Table won’t display; use Select-Object to choose columns instead.

Further reading: Out-GridView (Microsoft Learn)

More CLI tips printf 'GET /\r\n' | hexdump -C hexdump -C -s 512 -n 64 disk.img wget --limit-rate=2m https://example.com/big-file.iso wget --spider https://example.com/file.zip rg 'apiKey' -g '!*.min.js' -g '!package-lock.json' All CLI tips (46) All topics

Link