You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The **Out-ConsoleGridView** cmdlet sends the output from a command to a grid view window where the output is displayed in an interactive table.
24
27
25
28
You can use the following features of the table to examine your data:
26
29
27
-
- Hide, Show, and Reorder Columns: To hide, show, use the columns dropdown. Drag and drop column headers to reorder.
28
-
- Sort. To sort the data, click a column header. Click again to toggle from ascending to descending order.
29
-
- Quick Filter. Use the Filter box at the top of the window to search the text in the table. You can search for text in a particular column, search for literals, and search for multiple words.
30
-
- Column Filter. Use the Add Column Filter drop-down to create rules to filter the data. This is very useful for very large data sets, such as event logs.
30
+
- Quick Filter. Use the Filter box at the top of the window to search the text in the table. You can search for text in a particular column, search for literals, and search for multiple words. You can use the `-Filter` command to pre-populate the Filter box.
31
31
32
32
For instructions for using these features, type `Get-Help Out-ConsoleGridView -Full` and see How to Use the Grid View Window Features in the Notes section.
33
33
34
+
To send items from the interactive window down the pipeline, click to select the items (either the the mouse in terminals that support mouse or the `SPACE` key) and then press `ENTER`. `ESC` cancels.
35
+
34
36
## EXAMPLES
35
37
36
38
### Example 1: Output processes to a grid view
39
+
37
40
```PowerShell
38
41
PS C:\> Get-Process | Out-ConsoleGridView
39
42
```
40
43
41
44
This command gets the processes running on the local computer and sends them to a grid view window.
42
45
43
46
### Example 2: Use a variable to output processes to a grid view
47
+
44
48
```PowerShell
45
49
PS C:\> $P = Get-Process
46
-
PS C:\> $P | Out-ConsoleGridView
50
+
PS C:\> $P | Out-ConsoleGridView -OutputMode Single
47
51
```
48
52
49
53
This command also gets the processes running on the local computer and sends them to a grid view window.
@@ -52,8 +56,11 @@ The first command uses the Get-Process cmdlet to get the processes on the comput
52
56
53
57
The second command uses a pipeline operator to send the $P variable to **Out-ConsoleGridView**.
54
58
59
+
By specifying `-OutputMode Single` the grid view window will be restricted to a single selection, ensuring now more than a single object is returned.
60
+
55
61
### Example 3: Display a formatted table in a grid view
This command displays the processes that are running on the Server01 computer in a grid view window.
94
103
95
104
The command uses `ocgv`, which is the built-in alias for the **Out-ConsoleGridView** cmdlet, it uses the *Title* parameter to specify the window title.
96
105
97
-
### Example 6: Output data from remote computers to a grid view
This example shows the correct format for sending data collected from remote computers to the **Out-ConsoleGridView** cmdlet.
106
+
### Example 6: Define a function to kill processes using a graphical chooser
103
107
104
-
The command uses the Invoke-Command cmdlet to run a Get-Culture command on three remote computers.
105
-
It uses a pipeline operator to send the data that is returned to the **Out-ConsoleGridView** cmdlet.
108
+
```PowerShell
109
+
PS C:\> function killp { Get-Process | Out-ConsoleGridView -OutputMode Single -Filter $args[0] | Stop-Process -Id {$_.Id} }
110
+
PS C:\> killp note
111
+
```
112
+
This example shows defining a function named `killp` that shows a grid view of all running processes and allows the user to select one to kill it.
106
113
107
-
Notice that the script block that contains the commands that are run remotely does not include the **Out-ConsoleGridView** command.
108
-
If it did, the command would fail when it tried to open a grid view window on each of the remote computers.
114
+
The example uses the `-Filter` paramter to filter for all proceses with a name that includes `note` (thus highlighting `Notepad` if it were running. Selecting an item in the grid view and pressing `ENTER` will kill that process.
109
115
110
116
### Example 7: Pass multiple items through Out-ConsoleGridView
Save See [this gist](https://gist.github.com/tig/cbbeab7f53efd73e329afd6d4b838191) as `F7History.ps111 and run `F7History.ps1` in your `$profile`.
131
+
132
+
Press `F7` to see the history for the current PowerShell instance
133
+
134
+
Press `Shift-F7` to see the history for all PowerShell instances.
135
+
136
+
Whatever you select within `Out-ConsoleGridView` will be inserted on your command line.
137
+
138
+
Whatever was typed on the command line prior to hitting `F7` or `Shift-F7` will be used as a filter.
138
139
139
140
## PARAMETERS
140
141
142
+
### -Filter
143
+
Pre-populates the Filter edit box, allowing filtering to be specified on the command line.
144
+
145
+
```yaml
146
+
Type: String
147
+
Parameter Sets: (All)
148
+
Aliases:
149
+
150
+
Required: False
151
+
Position: Named
152
+
Default value: None
153
+
Accept pipeline input: False
154
+
Accept wildcard characters: False
155
+
```
156
+
141
157
### -InputObject
142
158
Specifies that the cmdlet accepts input for **Out-ConsoleGridView**.
143
159
144
160
When you use the **InputObject** parameter to send a collection of objects to **Out-ConsoleGridView**, **Out-ConsoleGridView** treats the collection as one collection object, and it displays one row that represents the collection.
161
+
145
162
To display the each object in the collection, use a pipeline operator (|) to send objects to **Out-ConsoleGridView**.
Specifies the items that the interactive window sends down the pipeline as input to other commands.
161
178
By default, this cmdlet does not generate any output.
162
-
To send items from the interactive window down the pipeline, click to select the items and then click OK.
179
+
180
+
To send items from the interactive window down the pipeline, click to select the items (either the the mouse in terminals that support mouse or the `SPACE` key) and then press `ENTER`. `ESC` cancels.
163
181
164
182
The values of this parameter determine how many items you can send down the pipeline.
165
183
166
-
- None. No items. This is the default value.
184
+
- None. No items.
167
185
- Single. Zero items or one item. Use this value when the next command can take only one input object.
168
-
- Multiple. Zero, one, or many items. Use this value when the next command can take multiple input objects. This value is equivalent to the *Passthru* parameter.
186
+
- Multiple. Zero, one, or many items. Use this value when the next command can take multiple input objects. This is the default value.
169
187
170
188
```yaml
171
189
Type: OutputModeOption
@@ -175,27 +193,7 @@ Accepted values: None, Single, Multiple
175
193
176
194
Required: False
177
195
Position: Named
178
-
Default value: None
179
-
Accept pipeline input: False
180
-
Accept wildcard characters: False
181
-
```
182
-
183
-
### -PassThru
184
-
Indicates that the cmdlet sends items from the interactive window down the pipeline as input to other commands.
185
-
By default, this cmdlet does not generate any output.
186
-
This parameter is equivalent to using the Multiple value of the *OutputMode* parameter.
187
-
188
-
To send items from the interactive window down the pipeline, click to select the items and then click OK.
189
-
Shift-click and Ctrl-click are supported.
190
-
191
-
```yaml
192
-
Type: SwitchParameter
193
-
Parameter Sets: PassThru
194
-
Aliases:
195
-
196
-
Required: False
197
-
Position: Named
198
-
Default value: None
196
+
Default value: Multiple
199
197
Accept pipeline input: False
200
198
Accept wildcard characters: False
201
199
```
@@ -223,96 +221,25 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
223
221
## INPUTS
224
222
225
223
### System.Management.Automation.PSObject
224
+
226
225
You can send any object to this cmdlet.
227
226
228
227
## OUTPUTS
229
228
230
-
### None
229
+
### System.Object
231
230
232
-
Normally, `Out-ConsoleGridView` does not return any objects. When using the `PassThru` parameter, the objects representing the selected rows are returned to the pipeline.
231
+
By default `Out-ConsoleGridView` returns objects representing the selected rows to the pipeline. Use `-OutputMode` to change this behavior.
233
232
234
233
## NOTES
235
-
* The command output that you send to **Out-ConsoleGridView** cannot be formatted, such as by using the Format-Table or Format-Wide cmdlets. To select properties, use the Select-Object cmdlet.
236
-
* Deserialized output from remote commands might not be formatted correctly in the grid view window.
237
-
How to Use the Grid View Window Features
238
-
239
-
The following topics explain how to use the features of the window that **Out-ConsoleGridView** displays.
240
-
241
-
**How to Hide, Show, and Reorder Columns**
242
-
243
-
**To hide or show a column:**
244
-
245
-
1. Click on the Columns expander.
246
-
247
-
2. In the Columns expander, toggle Columns that should appear.
248
-
Only selected columns appear in the grid view window.
249
-
250
-
**To reorder columns:**
251
-
252
-
- Drag and drop the column into the desired location.
253
-
254
-
**How to Sort Table Data**
255
-
256
-
- To sort the data, click a column header.
257
234
258
-
- To change the sort order, click the column header again.
259
-
Each time you click the same header, the sort order toggles between ascending to descending order.
260
-
The current order is indicated by a triangle in the column header.
235
+
* The command output that you send to **Out-ConsoleGridView** should not be formatted, such as by using the Format-Table or Format-Wide cmdlets. To select properties, use the Select-Object cmdlet.
261
236
262
-
**How to Search in the Table (Quick Filter)**
263
-
264
-
Use the Filter box to search for data in the table.
265
-
When you type in the box, only items that include the typed text appear in the table.
266
-
267
-
- Search for text.
268
-
To search for text in the table, in the Filter box, type the text to find.
269
-
270
-
- Search for multiple words.
271
-
To search for multiple words in the table, type the words separated by spaces.
272
-
**Out-ConsoleGridView** displays rows that include all of the words (logical AND).
273
-
274
-
- Search for literal phrases.
275
-
To search for phrases that include spaces or special characters, enclose the phrase in quotation marks.
276
-
**Out-ConsoleGridView** displays rows that include an exact match for the phrase.
277
-
278
-
**Use Column Filters to Filter the Table**
279
-
280
-
You can use column filters to determine which items are displayed in the table.
281
-
Items appear only when they satisfy all of the column filters that you establish.
282
-
283
-
Each column filter has the following format:
284
-
285
-
\<column\> \<operator\> \<value\>
286
-
287
-
Column filters for different properties are connected by AND.
288
-
Column filters for the same property are connected by OR.
289
-
You cannot change the logical connectors.
290
-
291
-
The column filters only affects the display.
292
-
It does not delete items from the table.
293
-
294
-
**How to Add Column Filters**
295
-
296
-
1. Click the Add Column Filters menu button.
297
-
298
-
2. Click the column (property) you wish to add.
299
-
300
-
**How to Edit a Column Filter**
301
-
302
-
- To change an operator, click the operator drop down, and then click to select a different operator from the drop-down list.
303
-
304
-
- To enter or change a value, type a value in the value box.
305
-
306
-
- To create an OR statement, add a column filter with the same property.
307
-
308
-
**How to Delete Column Filters**
309
-
310
-
- To delete selected column filters, click the remove button beside each column filter.
311
-
312
-
- To delete all column filters, click the Clear Filters button.
237
+
* Deserialized output from remote commands might not be formatted correctly in the grid view window.
0 commit comments