Skip to content

Commit b30200b

Browse files
see changelog for v2.5.0
1 parent 7bafef9 commit b30200b

25 files changed

+946
-125
lines changed

PSScriptTools.psd1

96 Bytes
Binary file not shown.

README.md

Lines changed: 74 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,10 @@ This command is designed to take pipeline input and display it in a colorized fo
163163

164164
You can use a simple hashtable to define a color if the given property matches the hashtable key.
165165

166-
![](./images/occ-1.png)
166+
![out-conditionalcolor-1](./images/occ-1.png)
167167

168168
Or you can specify an ordered hashtable for more complex processing.
169-
![](./images/occ-2.png)
169+
![out-conditionalcolor-2](./images/occ-2.png)
170170

171171
This command doesn't always work depending on the type of object you pipe to it. The problem appears to be related to the formatting system. Development and testing is ongoing.
172172

@@ -178,22 +178,61 @@ This command will copy a PowerShell command, including parameters and help to a
178178

179179
A set of simple commands to make it easier to format values.
180180

181+
### [Format-Percent](docs/Format-Percent.md)
182+
183+
Treat a value as a percentage. This will write a [double] and not include the % sign.
184+
181185
```powershell
182186
PS C:\> format-percent -Value 123.5646MB -total 1GB -Decimal 4
183187
12.0669
188+
```
189+
190+
### [Format-String](docs/Format-String.md)
191+
192+
Use this command to perform one of several string manipulation "tricks".
193+
194+
```powershell
184195
PS C:\> format-string "powershell" -Reverse -Case Proper
185196
Llehsrewop
197+
PS C:\> format-string PowerShell -Randomize
198+
wSlhoeePlr
199+
PS C:\> format-string "!MySecretPWord" -Randomize -Replace @{S="$";e=&{Get-Random -min 1 -max 9};o="^"} -Reverse
200+
yr7!^7WcMtr$Pd
201+
```
202+
203+
### [Format-Value](docs/Format-Value.md)
204+
205+
This command will format a given numeric value. By default it will treat the number as an integer. Or you can specify a certain number of decimal places. The command will also allow you to format the value in KB, MB, etc.
206+
207+
```powershell
186208
PS C:\> format-value 1235465676 -Unit kb
187209
1206509
210+
PS C:\> format-value 123.45 -AsCurrency
211+
$123.45
212+
PS C:\> (get-process | measure ws -sum).sum | format-value -Unit mb | format-value -AsNumber
213+
9,437
214+
```
215+
216+
Or pull it all together:
217+
218+
```powershell
219+
PS C:\> get-ciminstance win32_operatingsystem |
220+
select-object @{Name = "TotalMemGB";Expression={Format-Value $_.TotalVisibleMemorySize -Unit mb}},
221+
@{Name="FreeMemGB";Expression={Format-Value $_.FreePhysicalMemory -unit mb -Decimal 2}},
222+
@{Name="PctFree";Expression={Format-Percent -Value $_.FreePhysicalMemory -Total $_.totalVisibleMemorySize -Decimal 2}}
223+
224+
TotalMemGB FreeMemGB PctFree
225+
---------- --------- -------
226+
32 14.05 44.06
188227
```
189228

190229
## [Get-PSLocation](docs/Get-PSLocation.md)
191230

192231
A simple function to get common locations. This can be useful with cross-platform scripting.
193232

194-
![](./images/pslocation-win.png)
233+
![windows locations](./images/pslocation-win.png)
195234

196-
![](./images/pslocation-linux.png)
235+
![linux locations](./images/pslocation-linux.png)
197236

198237
## [Get-PowerShellEngine](docs/Get-PowerShellEngine.md)
199238

@@ -229,7 +268,7 @@ This command provides a PowerShell alternative to the cmd.exe **MORE** command,
229268
get-service | out-more
230269
```
231270

232-
![](./images/out-more.png)
271+
![out-more](./images/out-more.png)
233272

234273
This also works in PowerShell Core.
235274

@@ -243,11 +282,11 @@ Because this module is intended to make scripting easier for you, it adds option
243282

244283
In the PowerShell ISE, you will get a new menu under Add-Ons
245284

246-
![](./images/todo-1.png)
285+
![new menu](./images/todo-1.png)
247286

248287
You can use the menu or keyboard shortcut which will launch an input box.
249288

250-
![](./images/todo-2.png)
289+
![input box](./images/todo-2.png)
251290

252291
The comment will be inserted at the current cursor location.
253292

@@ -257,7 +296,7 @@ In VS Code, access the command palette (Ctrl+Shift+P) and then "PowerShell: Show
257296

258297
The primary command can be used to test a PowerShell expression or scriptblock for a specified number of times and calculate the average runtime, in milliseconds, over all the tests.
259298

260-
### Why?
299+
### Why
261300

262301
When you run a single test with `Measure-Command` the result might be affected by any number of factors. Likewise, running multiple tests may also be influenced by things such as caching. The goal in this module is to provide a test framework where you can run a test repeatedly with either a static or random interval between each test. The results are aggregated and analyzed. Hopefully, this will provide a more meaningful or realistic result.
263302

@@ -350,15 +389,15 @@ This function is a graphical replacement for `Read-Host`. It creates a simple WP
350389
$name = Invoke-InputBox -Prompt "Enter a user name" -Title "New User Setup"
351390
```
352391

353-
![](./images/ibx-1.png)
392+
![input box](./images/ibx-1.png)
354393

355394
You can also capture a secure string.
356395

357396
```powershell
358397
Invoke-Inputbox -Prompt "Enter a password for $Name" -AsSecureString -BackgroundColor red
359398
```
360399

361-
![](./images/ibx-2.png)
400+
![secure input box](./images/ibx-2.png)
362401

363402
This example also demonstrates that you can change form's background color. This function will **not** work in PowerShell Core.
364403

@@ -405,6 +444,7 @@ ConvertTo-WPFGrid -Title "Event Log Report"
405444
![Displaying Eventlog Info](images/wpfgrid.png)
406445

407446
You can also have automatically refresh the data.
447+
408448
```powershell
409449
get-process | sort-object WS -Descending | Select -first 20 ID,Name,WS,VM,PM,Handles,StartTime |
410450
Convertto-WPFGrid -Refresh -timeout 20 -Title "Top Processes"
@@ -726,7 +766,7 @@ Monday, March 4, 2019 1:00:00 PM
726766

727767
Convert a universal datetime to the local time.
728768

729-
### [Get-MyTimeInfo](./Get-MyTimeInfo.md)
769+
### [Get-MyTimeInfo](docs/Get-MyTimeInfo.md)
730770

731771
Display a time settings for a collection of locations. This command is a PowerShell equivalent of a world clock. It will display a datetime value against a collection of locations. You can specify an ordered hashtable of locations and time zones. You can run command like:
732772

@@ -752,8 +792,30 @@ Now Home Seattle New Zealand
752792

753793
This is a handy command when traveling and your laptop is using a locally derived time and you want to see the time in other locations. It is recommended that you set a PSDefaultParameter value for the HomeTimeZone parameter in your PowerShell profile.
754794

795+
## Console Utilities
796+
797+
### [Set-ConsoleTitle](docs/Set-ConsoleTitle.md)
798+
799+
Set the title bar of the current PowerShell console window.
800+
801+
```powershell
802+
PS C:\> if (Test-IsAdministrator) { Set-ConsoleTitle "Administrator: $($PSVersionTable.PSedition) $($PSVersionTable.PSVersion)" -Verbose }
803+
VERBOSE: [10:33:17.0420820 BEGIN ] Starting Set-ConsoleTitle
804+
VERBOSE: [10:33:17.0440568 PROCESS] Setting console title to Administrator: Desktop 5.1.17763.316
805+
VERBOSE: Performing the operation "Set-ConsoleTitle" on target "Administrator: Desktop 5.1.17763.316".
806+
VERBOSE: [10:33:17.0584056 END ] Ending Set-ConsoleTitle
807+
```
808+
809+
### [Set-ConsoleColor](docs/Set-ConsoleColor.md)
810+
811+
Configure the foreground or background color of the current PowerShell console window. Note that if you are running the PSReadline module, this command won't work. You should use `Set-PSReadlineOption` or similar command to configure your session settings.
812+
813+
```powershell
814+
PS C:\> Set-ConsoleColor -background DarkGray -foreground Yellow
815+
```
816+
755817
## Compatibility
756818

757819
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.
758820

759-
*last updated 6 March, 2019*
821+
*last updated 11 March, 2019*

changelog.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Change Log for PSScriptTools
22

3+
## v2.5.0
4+
5+
+ fixed bug which was hiding the horizontal scroll bar in `ConvertTo-WPFGrid` (Issue #40)
6+
+ fixed bug which prevented status bar from updating when manually refreshing in `ConvertTo-WPFGrid` (Issue #34)
7+
+ Changed time display in `ConvertTo-WPFGrid as a timespan instead of raw seconds (Issue #41)
8+
+ Markdown help cleanup
9+
+ Added `Set-ConsoleTitle`
10+
+ Added `Set-ConsoleColor`
11+
+ Updated `README.md`
12+
313
## v2.4.0
414

515
+ Made datagrid in `ConvertTo-WPFGrid` read-only (Issue #38)

docs/Compare-Module.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,5 +142,4 @@ Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell
142142
143143
[Get-Module]()
144144
145-
[Update-Module]()
146-
145+
[Update-Module]()

docs/ConvertTo-UTCTime.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Monday, March 4, 2019 5:51:49 PM
4141
## PARAMETERS
4242

4343
### -DateTime
44-
+
44+
4545
Enter a Datetime value
4646

4747
```yaml

docs/Format-String.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
external help file: PSScriptTools-help.xml
33
Module Name: PSScriptTools
4-
online version:
4+
online version:
55
schema: 2.0.0
66
---
77

@@ -115,7 +115,7 @@ Accept wildcard characters: False
115115
116116
### -Case
117117
118-
Valid values are Upper, Lower, Proper, Alternate, and Toggle.
118+
Valid values are Upper, Lower, Proper, Alternate, and Toggle.
119119
120120
Proper case will capitalize the first letter of the string.
121121

docs/Format-Value.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
external help file: PSScriptTools-help.xml
33
Module Name: PSScriptTools
4-
online version:
4+
online version:
55
schema: 2.0.0
66
---
77

@@ -215,4 +215,3 @@ Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell
215215
[Format-String](./Format-String.md)
216216
217217
[Format-Percent](./Format-Percent.md)
218-

docs/Get-MyTimeInfo.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,4 +234,3 @@ Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell
234234
## RELATED LINKS
235235
236236
[Get-TimeZone]()
237-

docs/Get-MyVariable.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ c 8
8383
VERBOSE: Finished getting my variables
8484
8
8585
```
86+
8687
This sample function dot sources the script with this function. Within the function, Get-MyVariable is called specifying scope 1, or the parent scope. Scope 0 would be the scope of the Get-MyVariable function. Here's the result.
8788

8889
### EXAMPLE 5

docs/Get-PSLocation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Results on a Windows system.
3939
### EXAMPLE 2
4040

4141
```powershell
42-
PS C:\> get-pslocation
42+
PS C:\> get-pslocation
4343
4444
Temp : /tmp/
4545
Home : /home/jeff

docs/Get-PowerShellEngine.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
external help file: PSScriptTools-help.xml
33
Module Name: PSScriptTools
4-
online version:
4+
online version:
55
schema: 2.0.0
66
---
77

@@ -78,7 +78,7 @@ Include additional information. Not all properties may have values depending on
7878
```yaml
7979
Type: SwitchParameter
8080
Parameter Sets: (All)
81-
Aliases:
81+
Aliases:
8282

8383
Required: False
8484
Position: Named

docs/Get-WindowsVersion.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,4 +189,3 @@ Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell
189189
[WinVer.exe]()
190190
191191
[Invoke-Command]()
192-

docs/Get-WindowsVersionString.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,4 +179,3 @@ Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell
179179
[Get-WindowsVersion]()
180180
181181
[Winver.exe]()
182-

docs/New-CustomFileName.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
external help file: PSScriptTools-help.xml
33
Module Name: PSScriptTools
4-
online version:
4+
online version:
55
schema: 2.0.0
66
---
77

@@ -22,7 +22,7 @@ New-CustomFileName [-Template] <String> [-Case <String>] [<CommonParameters>]
2222
This command will generate a custom file name based on a template string that you provide. You can create a template string using any of these variables. Most of these should be self-explanatory
2323

2424
- %username
25-
- %computername
25+
- %computername
2626
- %year - 4 digit year
2727
- %yr - 2 digit year
2828
- %monthname - The abbreviated month name

docs/Optimize-Text.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Optimize-Text [[-Text] <String[]>] [-Filter <Regex>] [-Ignore <String>] [-ToUppe
2222
### object
2323

2424
```yaml
25-
Optimize-Text [[-Text] <String[]>] [-Filter <Regex>][-Ignore <String>] [-ToUpper] [-PropertyName <String>]
25+
Optimize-Text [[-Text] <String[]>] [-Filter <Regex>][-Ignore <String>] [-ToUpper] [-PropertyName <String>]
2626
[<CommonParameters>]
2727
```
2828

@@ -90,7 +90,7 @@ bits Running dc01
9090
bits Running app02
9191
```
9292

93-
Optimize the computernames in computers.txt and add a Computername property. Test each computer, ignoring those that fail, and get the Bits service on the ones that can be pinged.
93+
Optimize the computer names in computers.txt and add a Computername property. Test each computer, ignoring those that fail, and get the Bits service on the ones that can be pinged.
9494

9595
### EXAMPLE 4
9696

docs/PSScriptTools.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,4 +181,12 @@ Convert a universal time to local time.
181181

182182
### [Get-MyTimeInfo](./Get-MyTimeInfo.md)
183183

184-
Display a time settings for a collection of locations
184+
Display a time settings for a collection of locations.
185+
186+
### [Set-ConsoleTitle](./Set-ConsoleTitle)
187+
188+
Set the title bar of the current PowerShell console window.
189+
190+
### [Set-ConsoleColor](./Set-ConsoleColor)
191+
192+
Configure the foreground or background color of the current PowerShell console window.

0 commit comments

Comments
 (0)