Sunday, February 20, 2011

Using Windows PowerShell as an IT Pro – Part 10

Using Windows PowerShell as an IT Pro – Part 10

In my last post I reviewed some the format cmdlets. Now I will play with the Out-Gridview cmdlet.
Windows PowerShell 2.0 provides a few new tools that help to treat you more like a human than a machine. For example, by using the Out-Gridview cmdlet after retrieving a list of items, you can have the output is pipelined to a separate window (Graphic 24).
Get-Service | Out-Gridview


From this window, the list can be sorted by clicking the column header. However, this is output from the command, not the objects themselves, preventing any manipulation directly from this window. For example, you cannot right-click an item here to get a context menu to appear in order to stop or start a service.

The PowerShell grid also includes a rudimentary filtering function, showing only those services whose returned data includes a specified keyword. Simply type that keyword in the text box labeled Search. After entering the keyword, the grid filters out any items that do not include that keyword in at least one of the columns.

If you want to limit the filter to a specific column, type the column name followed by a colon, and then the filter string, reducing the results to four services on the computer in this example.

In my next post we get into variables and types.

No comments:

Post a Comment