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
+63-56Lines changed: 63 additions & 56 deletions
Original file line number
Diff line number
Diff line change
@@ -23,6 +23,7 @@ Starting in v2.2.0, the module was restructured to better support Desktop and Co
23
23
```powershell
24
24
Uninstall-Module PSScriptTools -allversions
25
25
```
26
+
26
27
Any command that uses WPF will not run on PowerShell Core and is not exported.
27
28
28
29
Please post any questions, problems or feedback in [Issues](https://github.com/jdhitsolutions/PSScriptTools/issues). Any input is greatly appreciated.
@@ -232,26 +233,6 @@ get-service | out-more
232
233
233
234
This also works in PowerShell Core.
234
235
235
-
## [Invoke-InputBox](docs/Invoke-InputBox.md)
236
-
237
-
This function is a graphical replacement for `Read-Host`. It creates a simple WPF form that you can use to get user input. The value of the text box will be written to the pipeline.
238
-
239
-
```powershell
240
-
$name = Invoke-InputBox -Prompt "Enter a user name" -Title "New User Setup"
241
-
```
242
-
243
-

244
-
245
-
You can also capture a secure string.
246
-
247
-
```powershell
248
-
Invoke-Inputbox -Prompt "Enter a password for $Name" -AsSecureString -BackgroundColor red
249
-
```
250
-
251
-

252
-
253
-
This example also demonstrates that you can change form's background color. This function will **not** work in PowerShell Core.
254
-
255
236
## ToDo
256
237
257
238
Because this module is intended to make scripting easier for you, it adds options to insert ToDo statements into PowerShell files. If you are using the PowerShell ISE or VS Code and import this module, it will add the capability to insert a line like this:
@@ -359,9 +340,59 @@ which generates this markdown:
359
340
360
341
Because the function writes markdown to the pipeline you will need to pipe it to a command `Out-File` to create a file.
361
342
362
-
## [ConvertTo-WPFGrid](docs/ConvertTo-WPFGrid.md)
343
+
## Graphical Tools
344
+
345
+
## [Invoke-InputBox](docs/Invoke-InputBox.md)
346
+
347
+
This function is a graphical replacement for `Read-Host`. It creates a simple WPF form that you can use to get user input. The value of the text box will be written to the pipeline.
348
+
349
+
```powershell
350
+
$name = Invoke-InputBox -Prompt "Enter a user name" -Title "New User Setup"
351
+
```
352
+
353
+

354
+
355
+
You can also capture a secure string.
356
+
357
+
```powershell
358
+
Invoke-Inputbox -Prompt "Enter a password for $Name" -AsSecureString -BackgroundColor red
359
+
```
360
+
361
+

362
+
363
+
This example also demonstrates that you can change form's background color. This function will **not** work in PowerShell Core.
This function creates a Windows Presentation Foundation (WPF) based message box. This is intended to replace the legacy MsgBox function from VBScript and the Windows Forms library. The command uses a set of predefined button sets, each of which will close the form and write a value to the pipeline.
368
+
369
+
OK = 1
370
+
371
+
Cancel = 0
372
+
373
+
Yes = $True
374
+
375
+
No = $False
363
376
364
-
This command is an alternative to `Out-Gridview`. It works much the same way. Run a PowerShell command and pipe it to this command. The output will be displayed in an autosized data grid. You can click on column headings to sort. You can resize columns and you can re-order columns.
377
+
You can also create an ordered hashtable of your own buttons and values. It is assumed you will typically use this function in a script where you can capture the output and take some action based on the value.
378
+
379
+
```powershell
380
+
PS C:\> New-WPFMessageBox -Message "Are you sure you want to do this?" -Title Confirm -Icon Question -ButtonSet YesNo
381
+
```
382
+
383
+

384
+
385
+
You can also create your own custom button set as well as modify the background color.
386
+
387
+
```powershell
388
+
PS C:\> New-WPFMessageBox -Message "Select a system option from these choices:" -Title "You Decide" -Background cornsilk -Icon Warning -CustomButtonSet ([ordered]@{"Reboot"=1;"Shutdown"=2;"Cancel"=3})
This command is an alternative to `Out-Gridview`. It works much the same way. Run a PowerShell command and pipe it to this command. The output will be displayed in an auto-sized data grid. You can click on column headings to sort. You can resize columns and you can re-order columns.
This function is similar to `Import-PowerShellDataFile`. But where that command can only process a file, this command
404
439
will take any hashtable-formatted string and convert it into an actual hashtable.
@@ -420,7 +455,7 @@ CreatedOn BOVINE320
420
455
421
456
The test.psd1 file is protected as a CMS Message. In this example, the contents are decoded as a string which is then in turn converted into an actual hashtable.
This command will take an object and create a hashtable based on its properties. You can have the hashtable exclude some properties as well as properties that have no value.
442
477
@@ -451,7 +486,7 @@ Id 3456
451
486
Handles 958
452
487
```
453
488
454
-
## [Join-Hashtable](docs/Join-Hashtable.md)
489
+
###[Join-Hashtable](docs/Join-Hashtable.md)
455
490
456
491
This command will combine two hashtables into a single hashtable.Join-Hashtable will test for duplicate keys. If any of the keys from the first, or primary hashtable are found in the secondary hashtable, you will be prompted for which to keep. Or you can use -Force which will always keep the conflicting key from the first hashtable.
457
492
@@ -538,34 +573,6 @@ By default, the output will only show directory or equivalent structures. But yo
538
573
539
574

540
575
541
-
## [New-WPFMessageBox](docs/New-WPFMessageBox.md)
542
-
543
-
This function creates a Windows Presentation Foundation (WPF) based message box. This is intended to replace the legacy MsgBox function from VBScript and the Windows Forms library. The command uses a set of predefined button sets, each of which will close the form and write a value to the pipeline.
544
-
545
-
OK = 1
546
-
547
-
Cancel = 0
548
-
549
-
Yes = $True
550
-
551
-
No = $False
552
-
553
-
You can also create an ordered hashtable of your own buttons and values. It is assumed you will typically use this function in a script where you can capture the output and take some action based on the value.
554
-
555
-
```powershell
556
-
PS C:\> New-WPFMessageBox -Message "Are you sure you want to do this?" -Title Confirm -Icon Question -ButtonSet YesNo
557
-
```
558
-
559
-

560
-
561
-
You can also create your own custom button set as well as modify the background color.
562
-
563
-
```powershell
564
-
PS C:\> New-WPFMessageBox -Message "Select a system option from these choices:" -Title "You Decide" -Background cornsilk -Icon Warning -CustomButtonSet ([ordered]@{"Reboot"=1;"Shutdown"=2;"Cancel"=3})
Use this command to compare module versions between what is installed against an online repository like the PSGallery
@@ -749,4 +756,4 @@ This is a handy command when traveling and your laptop is using a locally derive
749
756
750
757
Where possible these commands have been tested with PowerShell Core, but not every platform. If you encounter problems, have suggestions or other feedback, please post an issue.
This command is an alternative to Out-Gridview. It works much the same way. Run a PowerShell command and pipe it to this command. The output will be displayed in an autosized data grid. You can click on column headings to sort. You can resize columns and you can re-order columns. You will want to be selective about which properties you pipe through to this command. See examples.
39
+
This command is an alternative to Out-Gridview. It works much the same way. Run a PowerShell command and pipe it to this command. The output will be displayed in an auto-sized data grid. You can click on column headings to sort. You can resize columns and you can re-order columns. You will want to be selective about which properties you pipe through to this command. See examples.
24
40
25
-
You can specify a timeout value which will automatically close the form. If you specify a timeout and the Refresh parameter, then the contents of the datagrid will automatically refreshed using the timeout value as an integer. This will only work when you pipe a PowerShell expression to ConvertTo-WPFGrid as one command. This will fail if you break the command in the PowerShell ISE or use a nested prompt.
41
+
You can specify a timeout value which will automatically close the form. If you specify a timeout and the Refresh parameter, then the contents of the datagrid will automatically refreshed using the timeout value as an integer. This will only work when you pipe a PowerShell expression to ConvertTo-WPFGrid as one command. This will fail if you break the command in the PowerShell ISE or use a nested prompt. Beginning with v2.4.0 the form now has a Refresh button which will automatically refresh the datagrid.
26
42
27
-
Because the grid is running in a new background runspace, it does not automatically inherit anything from your current session. When refreshing data, you need to make sure that the command up to ConvertTo-WPFGrid can run in a standalone session. For example, avoid using variables that won't exist in the background runspace. However, you can use the -UserProfile parameter which will load your user profile scripts into the runspace.
43
+
Because the grid is running in a new background runspace, it does not automatically inherit anything from your current session. However, you can use the -UserProfile parameter which will load your user profile scripts into the runspace. You can also specify a list of locally defined variables to be used in the form.
28
44
29
45
This command runs the WPF grid in a new runspace so your PowerShell prompt will not be blocked. However, after closing the form you may be left with the runspace. You can use Remove-Runspace to clean up or wait until you restart PowerShell.
Get Hyper-V virtual machine information and display for 20 seconds before automatically closing. Note that this would be written as one long pipelined expression. It is formatted here for the sake of the help documentation.
67
+
Get Hyper-V virtual machine information and refresh every 30 seconds. Because the command is using a locally defined variable it is also being used in the form. Note that this would be written as one long pipelined expression. It is formatted here for the sake of the help documentation.
52
68
53
69
### EXAMPLE 3
54
70
@@ -66,7 +82,7 @@ Typically the results of a PowerShell command or expression. You should select t
66
82
67
83
```yaml
68
84
Type: PSObject
69
-
Parameter Sets: (All)
85
+
Parameter Sets: Input
70
86
Aliases:
71
87
72
88
Required: False
@@ -131,6 +147,22 @@ Load your PowerShell profiles into the background runspace.
131
147
```yaml
132
148
Type: SwitchParameter
133
149
Parameter Sets: (All)
150
+
Aliases: profile
151
+
152
+
Required: False
153
+
Position: Named
154
+
Default value: None
155
+
Accept pipeline input: False
156
+
Accept wildcard characters: False
157
+
```
158
+
159
+
### -Scriptblock
160
+
161
+
Enter a scriptblock that will generate data to be populated in the form
162
+
163
+
```yaml
164
+
Type: ScriptBlock
165
+
Parameter Sets: scriptblock
134
166
Aliases:
135
167
136
168
Required: False
@@ -140,6 +172,22 @@ Accept pipeline input: False
140
172
Accept wildcard characters: False
141
173
```
142
174
175
+
### -UseLocalVariable
176
+
177
+
Load locally defined variables into the background runspace
178
+
179
+
```yaml
180
+
Type: String[]
181
+
Parameter Sets: (All)
182
+
Aliases: var
183
+
184
+
Required: False
185
+
Position: Named
186
+
Default value: None
187
+
Accept pipeline input: False
188
+
Accept wildcard characters: False
189
+
```
190
+
143
191
### CommonParameters
144
192
145
193
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
0 commit comments