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
Copy file name to clipboardExpand all lines: README.md
+6-3Lines changed: 6 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@
3
3
The GraphicalTools repo contains several different graphical-related PowerShell modules including:
4
4
5
5
*`Microsoft.PowerShell.GraphicalTools` - A module that provides GUI experiences based on Avalonia.
6
-
*`Microsoft.PowerShell.ConsoleGuiTools` - A module that provides console-based GUI experiences based on gui.cs.
6
+
*`Microsoft.PowerShell.ConsoleGuiTools` - A module that provides console-based GUI experiences based on [Terminal.Gui (gui.cs)](https://github.com/migueldeicaza/gui.cs).
The **Out-ConsoleGridView** cmdlet sends the output from a command to a grid view window where the output is displayed in an interactive table.
30
27
31
28
You can use the following features of the table to examine your data:
32
29
33
-
- Hide, Show, and Reorder Columns: To hide, show, use the columns dropdown. Drag and drop column headers to reorder.
34
-
- Sort. To sort the data, click a column header. Click again to toggle from ascending to descending order.
35
-
- 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.
36
-
- 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.
37
31
38
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.
39
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
+
40
36
## EXAMPLES
41
37
42
38
### Example 1: Output processes to a grid view
43
-
```
39
+
40
+
```PowerShell
44
41
PS C:\> Get-Process | Out-ConsoleGridView
45
42
```
46
43
47
44
This command gets the processes running on the local computer and sends them to a grid view window.
48
45
49
46
### Example 2: Use a variable to output processes to a grid view
50
-
```
47
+
48
+
```PowerShell
51
49
PS C:\> $P = Get-Process
52
-
PS C:\> $P | Out-ConsoleGridView
50
+
PS C:\> $P | Out-ConsoleGridView -OutputMode Single
53
51
```
54
52
55
53
This command also gets the processes running on the local computer and sends them to a grid view window.
@@ -58,8 +56,11 @@ The first command uses the Get-Process cmdlet to get the processes on the comput
58
56
59
57
The second command uses a pipeline operator to send the $P variable to **Out-ConsoleGridView**.
60
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
+
61
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.
100
103
101
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.
102
105
103
-
### 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
109
107
110
-
The command uses the Invoke-Command cmdlet to run a Get-Culture command on three remote computers.
111
-
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.
112
113
113
-
Notice that the script block that contains the commands that are run remotely does not include the **Out-ConsoleGridView** command.
114
-
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.
115
115
116
116
### Example 7: Pass multiple items through Out-ConsoleGridView
@@ -124,12 +125,40 @@ The processes that you select are passed to the **Export-Csv** command and writt
124
125
The command uses the *PassThru* parameter of **Out-ConsoleGridView**, which lets you send multiple items down the pipeline.
125
126
The *PassThru* parameter is equivalent to using the Multiple value of the *OutputMode* parameter.
126
127
128
+
### Example 8: Use F7 as "Show Command History"
129
+
130
+
Save See [this gist](https://gist.github.com/tig/cbbeab7f53efd73e329afd6d4b838191) as `F7History.ps1` 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.
139
+
127
140
## PARAMETERS
128
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
+
129
157
### -InputObject
130
158
Specifies that the cmdlet accepts input for **Out-ConsoleGridView**.
131
159
132
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
+
133
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.
149
178
By default, this cmdlet does not generate any output.
150
-
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.
151
181
152
182
The values of this parameter determine how many items you can send down the pipeline.
153
183
154
-
- None. No items. This is the default value.
184
+
- None. No items.
155
185
- Single. Zero items or one item. Use this value when the next command can take only one input object.
156
-
- 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.
157
187
158
188
```yaml
159
189
Type: OutputModeOption
@@ -163,27 +193,7 @@ Accepted values: None, Single, Multiple
163
193
164
194
Required: False
165
195
Position: Named
166
-
Default value: None
167
-
Accept pipeline input: False
168
-
Accept wildcard characters: False
169
-
```
170
-
171
-
### -PassThru
172
-
Indicates that the cmdlet sends items from the interactive window down the pipeline as input to other commands.
173
-
By default, this cmdlet does not generate any output.
174
-
This parameter is equivalent to using the Multiple value of the *OutputMode* parameter.
175
-
176
-
To send items from the interactive window down the pipeline, click to select the items and then click OK.
177
-
Shift-click and Ctrl-click are supported.
178
-
179
-
```yaml
180
-
Type: SwitchParameter
181
-
Parameter Sets: PassThru
182
-
Aliases:
183
-
184
-
Required: False
185
-
Position: Named
186
-
Default value: None
196
+
Default value: Multiple
187
197
Accept pipeline input: False
188
198
Accept wildcard characters: False
189
199
```
@@ -211,96 +221,25 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
211
221
## INPUTS
212
222
213
223
### System.Management.Automation.PSObject
224
+
214
225
You can send any object to this cmdlet.
215
226
216
227
## OUTPUTS
217
228
218
-
### None
229
+
### System.Object
219
230
220
-
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.
221
232
222
233
## NOTES
223
-
* 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.
224
-
* Deserialized output from remote commands might not be formatted correctly in the grid view window.
225
-
How to Use the Grid View Window Features
226
-
227
-
The following topics explain how to use the features of the window that **Out-ConsoleGridView** displays.
228
-
229
-
**How to Hide, Show, and Reorder Columns**
230
-
231
-
**To hide or show a column:**
232
-
233
-
1. Click on the Columns expander.
234
-
235
-
2. In the Columns expander, toggle Columns that should appear.
236
-
Only selected columns appear in the grid view window.
237
-
238
-
**To reorder columns:**
239
-
240
-
- Drag and drop the column into the desired location.
241
-
242
-
**How to Sort Table Data**
243
234
244
-
- To sort the data, click a 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.
245
236
246
-
- To change the sort order, click the column header again.
247
-
Each time you click the same header, the sort order toggles between ascending to descending order.
248
-
The current order is indicated by a triangle in the column header.
249
-
250
-
**How to Search in the Table (Quick Filter)**
251
-
252
-
Use the Filter box to search for data in the table.
253
-
When you type in the box, only items that include the typed text appear in the table.
254
-
255
-
- Search for text.
256
-
To search for text in the table, in the Filter box, type the text to find.
257
-
258
-
- Search for multiple words.
259
-
To search for multiple words in the table, type the words separated by spaces.
260
-
**Out-ConsoleGridView** displays rows that include all of the words (logical AND).
261
-
262
-
- Search for literal phrases.
263
-
To search for phrases that include spaces or special characters, enclose the phrase in quotation marks.
264
-
**Out-ConsoleGridView** displays rows that include an exact match for the phrase.
265
-
266
-
**Use Column Filters to Filter the Table**
267
-
268
-
You can use column filters to determine which items are displayed in the table.
269
-
Items appear only when they satisfy all of the column filters that you establish.
270
-
271
-
Each column filter has the following format:
272
-
273
-
\<column\> \<operator\> \<value\>
274
-
275
-
Column filters for different properties are connected by AND.
276
-
Column filters for the same property are connected by OR.
277
-
You cannot change the logical connectors.
278
-
279
-
The column filters only affects the display.
280
-
It does not delete items from the table.
281
-
282
-
**How to Add Column Filters**
283
-
284
-
1. Click the Add Column Filters menu button.
285
-
286
-
2. Click the column (property) you wish to add.
287
-
288
-
**How to Edit a Column Filter**
289
-
290
-
- To change an operator, click the operator drop down, and then click to select a different operator from the drop-down list.
291
-
292
-
- To enter or change a value, type a value in the value box.
293
-
294
-
- To create an OR statement, add a column filter with the same property.
295
-
296
-
**How to Delete Column Filters**
297
-
298
-
- To delete selected column filters, click the remove button beside each column filter.
299
-
300
-
- 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