Out-GridView Revisited

Out-GridView Revisited

  • Comments 15

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

Leave a Comment
  • Please add 8 and 8 and type the answer here:
  • Post
  • PingBack from http://www.anith.com/?p=17975

  • It should be mentioned that the current version (CTP3) of the gridview will max display 10 columns.

    From what I have heard this limitation is "hard-coded" will be fixed.

  • Yes, the "10 column limit" will be lifted in the next release of Windows PowerShell.

  • Is it possible to update the out-gridview with fresh data?

  • Also, when using the "Select-Object" to select columns, can you still include the hidden columns in the "Select Columns" UI, so they can be added on later if needed (without having to run the query again)?

  • Q: Is it possible to update the out-gridview with fresh data?

    A: Out-GridView window does not refresh itself, you have to pipe the updated data to Out-GridView cmdlet again.

  • Q: when using the "Select-Object" to select columns, can you still include the hidden columns in the "Select Columns" UI, so they can be added on later if needed (without having to run the query again)?

    A: After data, either selected or not, is piped to Out-GridView window, the data will be all the info Out-GridWindow consumes. Therefore, Out-GridView window does not have any info on those "hidden columns". From this aspect, "Select Columns" UI gives us more flexibility since we don't have to run "Select-Object" again to refresh the Out-GridView window layout. I was not aware of this difference until reading your questions. Thanks!

  • I assume that out-gridview is derived from a class in the system.windows.forms namespace for .NET verison 3.5.

    Do you know which one it uses?

  • Regular expression support in the filter would be killer.

  • Q: I assume that out-gridview is derived from a class in the system.windows.forms namespace for .NET verison 3.5. Do you know which one it uses?

    A: The System.Windows.Window class for .NET 3.5 is used to show the Out-GridView output.

  • Well, to me it seems MS have lifted the 10 columns limit, just to create a 30 column limit.

    Why?

  • Hi, out-gridview is a great tool but as it is an object, why not treat it like one? when created it should return a variable like:

    $a=get-process|out-gridview

    After selecting a row in the grid you could then retrieve the selected object using:

    $a.selecteditem

    This would be a lovely way of selecting the particular item you want out of a long array graphically, and get the object at the end rather than just a line of text.

  • Out-GridView not installed on 2008 production server? everything else there.

    wonder how did that happen

  • Out-GridView not installed on 2008 production server? everything else there.

    wonder how did that happen

  • Hi,

    can we save the output from a command with out-gridview? I mean, get-process | out-gridview it should save this get-process somewhere in grid view format so that even after some time I double click it, it should open the output in grid view.

    Chaitanya.

Page 1 of 1 (15 items)