Skip to content

Commit

Permalink
see changelog for v2.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jdhitsolutions committed Mar 11, 2019
1 parent 7bafef9 commit b30200b
Show file tree
Hide file tree
Showing 25 changed files with 946 additions and 125 deletions.
Binary file modified PSScriptTools.psd1
Binary file not shown.
86 changes: 74 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,10 @@ This command is designed to take pipeline input and display it in a colorized fo

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

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

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

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.

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

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

### [Format-Percent](docs/Format-Percent.md)

Treat a value as a percentage. This will write a [double] and not include the % sign.

```powershell
PS C:\> format-percent -Value 123.5646MB -total 1GB -Decimal 4
12.0669
```

### [Format-String](docs/Format-String.md)

Use this command to perform one of several string manipulation "tricks".

```powershell
PS C:\> format-string "powershell" -Reverse -Case Proper
Llehsrewop
PS C:\> format-string PowerShell -Randomize
wSlhoeePlr
PS C:\> format-string "!MySecretPWord" -Randomize -Replace @{S="$";e=&{Get-Random -min 1 -max 9};o="^"} -Reverse
yr7!^7WcMtr$Pd
```

### [Format-Value](docs/Format-Value.md)

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.

```powershell
PS C:\> format-value 1235465676 -Unit kb
1206509
PS C:\> format-value 123.45 -AsCurrency
$123.45
PS C:\> (get-process | measure ws -sum).sum | format-value -Unit mb | format-value -AsNumber
9,437
```

Or pull it all together:

```powershell
PS C:\> get-ciminstance win32_operatingsystem |
select-object @{Name = "TotalMemGB";Expression={Format-Value $_.TotalVisibleMemorySize -Unit mb}},
@{Name="FreeMemGB";Expression={Format-Value $_.FreePhysicalMemory -unit mb -Decimal 2}},
@{Name="PctFree";Expression={Format-Percent -Value $_.FreePhysicalMemory -Total $_.totalVisibleMemorySize -Decimal 2}}
TotalMemGB FreeMemGB PctFree
---------- --------- -------
32 14.05 44.06
```

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

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

![](./images/pslocation-win.png)
![windows locations](./images/pslocation-win.png)

![](./images/pslocation-linux.png)
![linux locations](./images/pslocation-linux.png)

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

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

![](./images/out-more.png)
![out-more](./images/out-more.png)

This also works in PowerShell Core.

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

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

![](./images/todo-1.png)
![new menu](./images/todo-1.png)

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

![](./images/todo-2.png)
![input box](./images/todo-2.png)

The comment will be inserted at the current cursor location.

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

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.

### Why?
### Why

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.

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

![](./images/ibx-1.png)
![input box](./images/ibx-1.png)

You can also capture a secure string.

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

![](./images/ibx-2.png)
![secure input box](./images/ibx-2.png)

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

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

You can also have automatically refresh the data.

```powershell
get-process | sort-object WS -Descending | Select -first 20 ID,Name,WS,VM,PM,Handles,StartTime |
Convertto-WPFGrid -Refresh -timeout 20 -Title "Top Processes"
Expand Down Expand Up @@ -726,7 +766,7 @@ Monday, March 4, 2019 1:00:00 PM

Convert a universal datetime to the local time.

### [Get-MyTimeInfo](./Get-MyTimeInfo.md)
### [Get-MyTimeInfo](docs/Get-MyTimeInfo.md)

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:

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

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.

## Console Utilities

### [Set-ConsoleTitle](docs/Set-ConsoleTitle.md)

Set the title bar of the current PowerShell console window.

```powershell
PS C:\> if (Test-IsAdministrator) { Set-ConsoleTitle "Administrator: $($PSVersionTable.PSedition) $($PSVersionTable.PSVersion)" -Verbose }
VERBOSE: [10:33:17.0420820 BEGIN ] Starting Set-ConsoleTitle
VERBOSE: [10:33:17.0440568 PROCESS] Setting console title to Administrator: Desktop 5.1.17763.316
VERBOSE: Performing the operation "Set-ConsoleTitle" on target "Administrator: Desktop 5.1.17763.316".
VERBOSE: [10:33:17.0584056 END ] Ending Set-ConsoleTitle
```

### [Set-ConsoleColor](docs/Set-ConsoleColor.md)

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.

```powershell
PS C:\> Set-ConsoleColor -background DarkGray -foreground Yellow
```

## Compatibility

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.

*last updated 6 March, 2019*
*last updated 11 March, 2019*
10 changes: 10 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Change Log for PSScriptTools

## v2.5.0

+ fixed bug which was hiding the horizontal scroll bar in `ConvertTo-WPFGrid` (Issue #40)
+ fixed bug which prevented status bar from updating when manually refreshing in `ConvertTo-WPFGrid` (Issue #34)
+ Changed time display in `ConvertTo-WPFGrid as a timespan instead of raw seconds (Issue #41)
+ Markdown help cleanup
+ Added `Set-ConsoleTitle`
+ Added `Set-ConsoleColor`
+ Updated `README.md`

## v2.4.0

+ Made datagrid in `ConvertTo-WPFGrid` read-only (Issue #38)
Expand Down
3 changes: 1 addition & 2 deletions docs/Compare-Module.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,5 +142,4 @@ Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell
[Get-Module]()
[Update-Module]()
[Update-Module]()
2 changes: 1 addition & 1 deletion docs/ConvertTo-UTCTime.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Monday, March 4, 2019 5:51:49 PM
## PARAMETERS

### -DateTime
+

Enter a Datetime value

```yaml
Expand Down
4 changes: 2 additions & 2 deletions docs/Format-String.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
external help file: PSScriptTools-help.xml
Module Name: PSScriptTools
online version:
online version:
schema: 2.0.0
---

Expand Down Expand Up @@ -115,7 +115,7 @@ Accept wildcard characters: False
### -Case
Valid values are Upper, Lower, Proper, Alternate, and Toggle.
Valid values are Upper, Lower, Proper, Alternate, and Toggle.
Proper case will capitalize the first letter of the string.
Expand Down
3 changes: 1 addition & 2 deletions docs/Format-Value.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
external help file: PSScriptTools-help.xml
Module Name: PSScriptTools
online version:
online version:
schema: 2.0.0
---

Expand Down Expand Up @@ -215,4 +215,3 @@ Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell
[Format-String](./Format-String.md)
[Format-Percent](./Format-Percent.md)
1 change: 0 additions & 1 deletion docs/Get-MyTimeInfo.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,4 +234,3 @@ Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell
## RELATED LINKS
[Get-TimeZone]()
1 change: 1 addition & 0 deletions docs/Get-MyVariable.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ c 8
VERBOSE: Finished getting my variables
8
```

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.

### EXAMPLE 5
Expand Down
2 changes: 1 addition & 1 deletion docs/Get-PSLocation.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Results on a Windows system.
### EXAMPLE 2

```powershell
PS C:\> get-pslocation
PS C:\> get-pslocation
Temp : /tmp/
Home : /home/jeff
Expand Down
4 changes: 2 additions & 2 deletions docs/Get-PowerShellEngine.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
external help file: PSScriptTools-help.xml
Module Name: PSScriptTools
online version:
online version:
schema: 2.0.0
---

Expand Down Expand Up @@ -78,7 +78,7 @@ Include additional information. Not all properties may have values depending on
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Aliases:

Required: False
Position: Named
Expand Down
1 change: 0 additions & 1 deletion docs/Get-WindowsVersion.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,4 +189,3 @@ Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell
[WinVer.exe]()
[Invoke-Command]()
1 change: 0 additions & 1 deletion docs/Get-WindowsVersionString.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,4 +179,3 @@ Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell
[Get-WindowsVersion]()
[Winver.exe]()
4 changes: 2 additions & 2 deletions docs/New-CustomFileName.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
external help file: PSScriptTools-help.xml
Module Name: PSScriptTools
online version:
online version:
schema: 2.0.0
---

Expand All @@ -22,7 +22,7 @@ New-CustomFileName [-Template] <String> [-Case <String>] [<CommonParameters>]
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

- %username
- %computername
- %computername
- %year - 4 digit year
- %yr - 2 digit year
- %monthname - The abbreviated month name
Expand Down
4 changes: 2 additions & 2 deletions docs/Optimize-Text.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Optimize-Text [[-Text] <String[]>] [-Filter <Regex>] [-Ignore <String>] [-ToUppe
### object

```yaml
Optimize-Text [[-Text] <String[]>] [-Filter <Regex>][-Ignore <String>] [-ToUpper] [-PropertyName <String>]
Optimize-Text [[-Text] <String[]>] [-Filter <Regex>][-Ignore <String>] [-ToUpper] [-PropertyName <String>]
[<CommonParameters>]
```

Expand Down Expand Up @@ -90,7 +90,7 @@ bits Running dc01
bits Running app02
```

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

### EXAMPLE 4

Expand Down
10 changes: 9 additions & 1 deletion docs/PSScriptTools.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,4 +181,12 @@ Convert a universal time to local time.

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

Display a time settings for a collection of locations
Display a time settings for a collection of locations.

### [Set-ConsoleTitle](./Set-ConsoleTitle)

Set the title bar of the current PowerShell console window.

### [Set-ConsoleColor](./Set-ConsoleColor)

Configure the foreground or background color of the current PowerShell console window.
Loading

0 comments on commit b30200b

Please sign in to comment.