Skip to content

Commit be4bea2

Browse files
committed
Merge branch 'master' of tig:PowerShell/GraphicalTools
2 parents 9d2c85a + b3abee1 commit be4bea2

File tree

14 files changed

+199
-190
lines changed

14 files changed

+199
-190
lines changed

.vscode/tasks.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@
1616
"args": [
1717
"-c",
1818
"Invoke-Build",
19-
"Build"
19+
// Build both modules
20+
//"Build -ModuleName Microsoft.PowerShell.GraphicalTools, Microsoft.PowerShell.ConsoleGuiTools",
21+
// Build only Out-GridView
22+
//"Build -ModuleName Microsoft.PowerShell.GraphicalTools",
23+
// Build only Out-ConsoleGridView
24+
"Build -ModuleName Microsoft.PowerShell.ConsoleGuiTools",
2025
],
2126
"problemMatcher": "$msCompile",
2227
"group": {

Build.ps1

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,11 @@
1-
Invoke-Build Build
2-
pwsh -noprofile -command "Import-Module '$PSScriptRoot/module/Microsoft.PowerShell.GraphicalTools'; Get-Process | Out-GridView -PassThru"
1+
# Build script for buildling/testing from the commnad line. See tasks.json for how build is invoked within VS Code
2+
# GraphicalTools includes two modules: Microsoft.PowerShell.GraphicalTools and Microsoft.PowerShell.ConsoleGuiTools
3+
# To build them all leave -ModuleName off the `InvokeBuild` command (e.g. Invoke-Build Build).
4+
# To build only one, specify it using the -ModuleName paramater (e.g. Invoke-Build Build -ModuleName Microsoft.PowerShell.ConsoleGuiTools).
5+
6+
# Build...
7+
Invoke-Build Build -ModuleName Microsoft.PowerShell.ConsoleGuiTools
8+
9+
# Run what was built...
10+
# pwsh -noprofile -command "Import-Module -verbose '$PSScriptRoot/module/Microsoft.PowerShell.GraphicalTools'; Get-Module -all | Out-GridView -OutputMode Single -Title 'Imported Modules'
11+
pwsh -noprofile -command "Import-Module -verbose '$PSScriptRoot/module/Microsoft.PowerShell.ConsoleGuiTools'; Get-Module -all | Out-ConsoleGridView -OutputMode Single -Title 'Imported Modules' -Filter power"

GraphicalTools.build.ps1

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ param(
33
[ValidateSet("Debug", "Release")]
44
[string]$Configuration = "Debug",
55

6-
[string[]]$ModuleName = @( "Microsoft.PowerShell.GraphicalTools", "Microsoft.PowerShell.ConsoleGuiTools" )
6+
[string[]]$ModuleName = @(
7+
"Microsoft.PowerShell.GraphicalTools",
8+
"Microsoft.PowerShell.ConsoleGuiTools" )
79
)
810

911
$script:IsUnix = $PSVersionTable.PSEdition -and $PSVersionTable.PSEdition -eq "Core" -and !$IsWindows

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
The GraphicalTools repo contains several different graphical-related PowerShell modules including:
44

55
* `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).
77

88
## Installation
99

@@ -23,6 +23,8 @@ Install-Module Microsoft.PowerShell.ConsoleGuiTools
2323

2424
### Microsoft.PowerShell.GraphicalTools
2525

26+
[Out-GridView documentation](docs/Microsoft.PowerShell.ConsoleGuiTools/Out-GridView.md)
27+
2628
#### Cross-Platform
2729
|Linux |Windows |Mac |
2830
|---|---|---|
@@ -34,7 +36,9 @@ Install-Module Microsoft.PowerShell.ConsoleGuiTools
3436

3537
### Microsoft.PowerShell.ConsoleGuiTools
3638

37-
![screenshot of Out-ConsoleGridView](https://pbs.twimg.com/media/ESyWfiqUYAA_t6q?format=jpg&name=medium)
39+
[Out-ConsoleGridView documentation](docs/Microsoft.PowerShell.ConsoleGuiTools/Out-ConsoleGridView.md)
40+
41+
![screenshot of Out-ConsoleGridView](docs/Microsoft.PowerShell.ConsoleGuiTools/ocgv.gif)
3842

3943
#### Cross-Platform
4044

@@ -116,7 +120,6 @@ In the Powershell session run your commands; breakpoints will be hit, etc...
116120

117121
When done, run `exit` to exit the nested PowerShell and run `pwsh` again. This unloads the DLL. Repeat.
118122

119-
120123
## Contributions Welcome!
121124

122125
We would love to incorporate community contributions into this project. If you would like to

docs/Microsoft.PowerShell.ConsoleGuiTools/Out-ConsoleGridView.md

Lines changed: 70 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -11,45 +11,43 @@ title: Out-ConsoleGridView
1111
# Out-ConsoleGridView
1212

1313
## SYNOPSIS
14+
1415
Sends output to an interactive table in the same console window.
1516

1617
## SYNTAX
1718

18-
### PassThru (Default)
19-
```
20-
Out-ConsoleGridView [-InputObject <PSObject>] [-Title <String>] [-PassThru] [<CommonParameters>]
21-
```
22-
23-
### OutputMode
24-
```
25-
Out-ConsoleGridView [-InputObject <PSObject>] [-Title <String>] [-OutputMode <OutputModeOption>] [<CommonParameters>]
19+
```PowerShell
20+
Out-ConsoleGridView [-InputObject <psobject>] [-Title <string>] [-OutputMode {None | Single |
21+
Multiple}] [-Filter <string>] [<CommonParameters>]
2622
```
2723

2824
## DESCRIPTION
25+
2926
The **Out-ConsoleGridView** cmdlet sends the output from a command to a grid view window where the output is displayed in an interactive table.
3027

3128
You can use the following features of the table to examine your data:
3229

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.
3731

3832
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.
3933

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+
4036
## EXAMPLES
4137

4238
### Example 1: Output processes to a grid view
43-
```
39+
40+
```PowerShell
4441
PS C:\> Get-Process | Out-ConsoleGridView
4542
```
4643

4744
This command gets the processes running on the local computer and sends them to a grid view window.
4845

4946
### Example 2: Use a variable to output processes to a grid view
50-
```
47+
48+
```PowerShell
5149
PS C:\> $P = Get-Process
52-
PS C:\> $P | Out-ConsoleGridView
50+
PS C:\> $P | Out-ConsoleGridView -OutputMode Single
5351
```
5452

5553
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
5856

5957
The second command uses a pipeline operator to send the $P variable to **Out-ConsoleGridView**.
6058

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+
6161
### Example 3: Display a formatted table in a grid view
62-
```
62+
63+
```PowerShell
6364
PS C:\> Get-Process | Select-Object -Property Name, WorkingSet, PeakWorkingSet | Sort-Object -Property WorkingSet -Descending | Out-ConsoleGridView
6465
```
6566

@@ -77,7 +78,8 @@ The final part of the command uses a pipeline operator (|) to send the formatted
7778
You can now use the features of the grid view to search, sort, and filter the data.
7879

7980
### Example 4: Save output to a variable, and then output a grid view
80-
```
81+
82+
```PowerShell
8183
PS C:\> ($A = Get-ChildItem -Path $pshome -Recurse) | Out-ConsoleGridView
8284
```
8385

@@ -92,29 +94,28 @@ The parentheses in the command establish the order of operations.
9294
As a result, the output from the Get-ChildItem command is saved in the $A variable before it is sent to **Out-ConsoleGridView**.
9395

9496
### Example 5: Output processes for a specified computer to a grid view
95-
```
97+
98+
```PowerShell
9699
PS C:\> Get-Process -ComputerName "Server01" | ocgv -Title "Processes - Server01"
97100
```
98101

99102
This command displays the processes that are running on the Server01 computer in a grid view window.
100103

101104
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.
102105

103-
### Example 6: Output data from remote computers to a grid view
104-
```
105-
PS C:\> Invoke-Command -ComputerName S1, S2, S3 -ScriptBlock {Get-Culture} | Out-ConsoleGridView
106-
```
107-
108-
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
109107

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.
112113

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.
115115

116116
### Example 7: Pass multiple items through Out-ConsoleGridView
117-
```
117+
118+
```PowerShell
118119
PS C:\> Get-Process | Out-ConsoleGridView -PassThru | Export-Csv -Path .\ProcessLog.csv
119120
```
120121

@@ -124,12 +125,40 @@ The processes that you select are passed to the **Export-Csv** command and writt
124125
The command uses the *PassThru* parameter of **Out-ConsoleGridView**, which lets you send multiple items down the pipeline.
125126
The *PassThru* parameter is equivalent to using the Multiple value of the *OutputMode* parameter.
126127

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+
127140
## PARAMETERS
128141

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+
129157
### -InputObject
130158
Specifies that the cmdlet accepts input for **Out-ConsoleGridView**.
131159
132160
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+
133162
To display the each object in the collection, use a pipeline operator (|) to send objects to **Out-ConsoleGridView**.
134163
135164
```yaml
@@ -147,13 +176,14 @@ Accept wildcard characters: False
147176
### -OutputMode
148177
Specifies the items that the interactive window sends down the pipeline as input to other commands.
149178
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.
151181

152182
The values of this parameter determine how many items you can send down the pipeline.
153183

154-
- None. No items. This is the default value.
184+
- None. No items.
155185
- 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.
157187

158188
```yaml
159189
Type: OutputModeOption
@@ -163,27 +193,7 @@ Accepted values: None, Single, Multiple
163193
164194
Required: False
165195
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
187197
Accept pipeline input: False
188198
Accept wildcard characters: False
189199
```
@@ -211,96 +221,25 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
211221
## INPUTS
212222

213223
### System.Management.Automation.PSObject
224+
214225
You can send any object to this cmdlet.
215226

216227
## OUTPUTS
217228

218-
### None
229+
### System.Object
219230

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.
221232

222233
## 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**
243234

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.
245236

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.
301238

302239
## RELATED LINKS
303240

241+
[Out-GridView](Out-GridView.md)
242+
304243
[Out-File](Out-File.md)
305244

306245
[Out-Printer](Out-Printer.md)
2.17 MB
Loading

0 commit comments

Comments
 (0)