March 11th, 2009

Out-GridView Revisited

PowerShell Team
PowerShell Team

It has been more than one year since we updated Out-GridView feature with you. In case you are not familiar with Out-GridView yet, it is a unique PowerShell cmdlet that users can pipe command output to a separate window, and it enables users organize and analyze output data easily. The previous blog entry by Brent gave an overview of Out-GridView cmdlet.

So, what’s new for Out-GridView in Windows PowerShell CTP3? A major feature we added was query filtering functionality; data can be queried according to their properties through this feature. Let’s look at an example. Running command: “Get-ChildItem | Out-GridView”, an Out-GridView window populated with all the file/directory data in the current directory will pop up. Clicking “Query” and “Add” buttons on the Out-GridView window, we will see all the properties for file/directory info: “Mode”, “LastWriteTime”, and etc. Assume we are interested in finding files/ directories with names containing string “do”, select “Name”, type “do” in the query text box, then we will have returned results: “Documents” and “Downloads”. In addition to query operator “contains”,  we have more operators, such as “starts with”, “ends with”  for users to compose more varieties of queries.

image

We also provided multiple ways to organize the layout of Out-GridView window. To select columns to display, you can use PowerShell cmdlet “Select-Object”. For example, “Get-ChildItem | Select-Object -Property Name,Length | Out-GridView” will only display “Name” and “Length” columns. The other way is through “Select Columns” UI. Click any column header, and click “Select Columns…”, then you can use the UI (shown below) to select the columns to be displayed. The columns in the “Selected columns” box will be displayed. With the  “Select Columns” UI, we can also use “move up/down” buttons to re-order the columns in the Out-GridView window. Alternatively, you can simply drag & drop a column to do re-ordering.

image

To offer a better GUI user experience, Out-GridView window supports multiple row selection and copy/paste. For selecting consecutive rows, you can click starting row, and press Shift key, then click ending row. To select non consecutive rows, click a row, press Ctrl key, and then click more rows. If you’d like to save the data in in word processing software or spreadsheet, use the generic “Ctrl + C” to copy the rows selected, and “Ctrl + V” to paste them.

 

Xin Li

Windows PowerShell Team

Category
PowerShell

Author

PowerShell Team
PowerShell Team

PowerShell is a task-based command-line shell and scripting language built on .NET. PowerShell helps system administrators and power-users rapidly automate tasks that manage operating systems (Linux, macOS, and Windows) and processes.

0 comments

Discussion are closed.