Skip to content

Commit

Permalink
v2.42.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jdhitsolutions committed Jan 24, 2022
1 parent e45ae72 commit de6891a
Show file tree
Hide file tree
Showing 15 changed files with 180 additions and 94 deletions.
37 changes: 37 additions & 0 deletions Archive-ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,43 @@

This file contains older change history. It is maintained for reference purposes.

## v2.39.0

+ Updated `Test-WithCulture` to include additional Verbose output.
+ Added command [Get-FileExtensionInfo](docs/Get-FileExtensionInfo.md) with format file `FileExtensionInfo.format.ps1xml'. This command will require PowerShell 7.
+ Added `New-PSDynamicParameter` and `New-PSDynamicParameterForm`.
+ Incorporated pull request [#116](https://github.com/jdhitsolutions/PSScriptTools/pull/116) to fix bug with `Get-ParameterInfo` when the command has a `count` parameter. Thanks @ninmonkey.
+ Added command [Get-LastModifiedFile](docs/Get-LastModifiedFile.md) and its alias *glm*.
+ Help updates.
+ Updated `README.md`.

## v2.38.0

+ Added `Get-PSUnique` function with an alias of `gpsu`. ([Issue #109](https://github.com/jdhitsolutions/PSScriptTools/issues/109)).
+ Modified `Show-AnsiSequence` to default to `Foreground` when using `-Type` ([Issue #110](https://github.com/jdhitsolutions/PSScriptTools/issues/110)).
+ Cleaned up module manifest.
+ Updated `New-PSFormatXML` to __not__ create the ps1xml file if a bad property is detected ([Issue #111](https://github.com/jdhitsolutions/PSScriptTools/issues/111)).
+ Modified `New-PSFormatXML` to __not__ add an explicit declaration. This means the files will now be saved in the correct UTF-8 format and not UTF-8 with BOM.
+ Modified TODO VSCode command to put date at the end. Otherwise, it breaks the `Better Comments` extension.
+ Added `Set-LocationToFile` which is only loaded when importing the module in VS Code or the PowerShell ISE.
+ Re-saved all `.ps1xml` files as `UTF-8`.
+ Added custom type extension files `fileinfo.types.ps1xml` and `system.diagnostics.process.types.ps1xml`.
+ Updated `README.md`.

## v2.37.0

+ Updated `Convertto-WPFGrid` to better handle non-standard property names. ([Issue #108](https://github.com/jdhitsolutions/PSScriptTools/issues/108)).
+ Modified custom format files that use ANSI to test if host name matches 'console' or 'code' to support VSCode.
+ Modified `Summary` view in `psparameterinfo.format.ps1xml` to not use autosizing.
+ Added `<AutoSize/>` back to `serviceansi.format.ps1xml` so that ANSI output displays properly.
+ Modified `Show-ANSI` and `Get-PSAnsiFileMap` to use `[char]27` instead of `[char]0x1b` for Windows PowerShell sessions.
+ Modified ANSI sequences in format files to use `[char]27`. ([Issue #107](https://github.com/jdhitsolutions/PSScriptTools/issues/107)).
+ Modified ANSI sequences in format files recognize a remote PSSession. ([Issue #106](https://github.com/jdhitsolutions/PSScriptTools/issues/106)).
+ Update `Get-PSLocation` to work in a PowerShell remoting session where there is no profile. ([Issue #104](https://github.com/jdhitsolutions/PSScriptTools/issues/104)).
+ Updated help.
+ Updated `README.md`.


## v2.36.0

+ Update `Get-MyVariable` to make it more compatible with PowerShell 7 ([Issue #103](https://github.com/jdhitsolutions/PSScriptTools/issues/103)). This also makes the command now compatible with the PowerShell ISE.
Expand Down
Binary file modified PSScriptTools.psd1
Binary file not shown.
Binary file modified PSScriptToolsManual.pdf
Binary file not shown.
103 changes: 61 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1641,53 +1641,12 @@ C:\work\Alpha\

This example is using parameter and command aliases. You can display a tree listing with files including user-specified properties. Use a value of * to show all properties.

### [New-ANSIBar](docs/New-ANSIBar.md)

You can use this command to create colorful bars using ANSI escape sequences based on a 256 color scheme. The default behavior is to create a gradient bar that goes from first to last values in the range and then back down again. Or you can create a single gradient that runs from the beginning of the range to the end. You can use one of the default characters or specify a custom one.

![New-ANSIBar](images/ansibar.png)

### [New-RedGreenGradient](docs/New-RedGreenGradient.md)

A related command is `New-RedGreenGradient`, which displays a bar going from red to green. This might be handy when you want to present a visual indicator.
`New-RedGreenGradient`, which displays a bar going from red to green. This might be handy when you want to present a visual indicator.

![New-RedGreenGradient](images/redgreen.png)

### [Write-ANSIProgress](docs/Write-ANSIProgress.md)

You could also use `Write-ANSIProgress` to show a custom ANSI bar.

![Write-ANSIProgress simple](images/write-ansprogress-1.png)

![write-ANSIProgress in code](images/write-ansprogress-2.png)

Or you can use it in your code to display a console progress bar.

```powershell
$sb = {
Clear-Host
$top = Get-ChildItem c:\scripts -Directory
$i = 0
$out=@()
$pos = $host.ui.RawUI.CursorPosition
Foreach ($item in $top) {
$i++
$pct = [math]::round($i/$top.count,2)
Write-ANSIProgress -PercentComplete $pct -position $pos
Write-Host " Processing $(($item.fullname).padright(80))"
-ForegroundColor Yellow -NoNewline
$out+= Get-ChildItem -path $item -Recurse -file |
Measure-Object -property length -sum |
Select-Object @{Name="Path";Expression={$item.fullname}},Count,
@{Name="Size";Expression={$_.Sum}}
}
Write-Host ""
$out | Sort-Object -property Size -Descending
}
```

![Write-ANSIProgress script](images/write-ansprogress-3.png)

## Format Functions

The module contains a set of simple commands to make it easier to format values.
Expand Down Expand Up @@ -2431,6 +2390,66 @@ To use the resulting value you still need to construct an ANSI string with the e

In PowerShell 7 you can use `` `e ``. Or `$([char]27)` which works in all PowerShell versions.

### [New-ANSIBar](docs/New-ANSIBar.md)

You can use this command to create colorful bars using ANSI escape sequences based on a 256 color scheme. The default behavior is to create a gradient bar that goes from first to last values in the range and then back down again. Or you can create a single gradient that runs from the beginning of the range to the end. You can use one of the default characters or specify a custom one.

![New-ANSIBar](images/ansibar.png)

### [Write-ANSIProgress](docs/Write-ANSIProgress.md)

You could also use `Write-ANSIProgress` to show a custom ANSI bar.

![Write-ANSIProgress simple](images/write-ansprogress-1.png)

![write-ANSIProgress in code](images/write-ansprogress-2.png)

Or you can use it in your code to display a console progress bar.

```powershell
$sb = {
Clear-Host
$top = Get-ChildItem c:\scripts -Directory
$i = 0
$out=@()
$pos = $host.ui.RawUI.CursorPosition
Foreach ($item in $top) {
$i++
$pct = [math]::round($i/$top.count,2)
Write-ANSIProgress -PercentComplete $pct -position $pos
Write-Host " Processing $(($item.fullname).padright(80))"
-ForegroundColor Yellow -NoNewline
$out+= Get-ChildItem -path $item -Recurse -file |
Measure-Object -property length -sum |
Select-Object @{Name="Path";Expression={$item.fullname}},Count,
@{Name="Size";Expression={$_.Sum}}
}
Write-Host ""
$out | Sort-Object -property Size -Descending
}
```

![Write-ANSIProgress script](images/write-ansprogress-3.png)


### [Show-ANSISequence](docs/Show-ANSISequence.md)

You can use `Show-ANSISequence` to preview how it will look in your PowerShell session. You might get a difference appearance in Windows Terminal depending on the color scheme you are using.

The default behavior is to show basic sequences.

![show basic ansi sequence](images/show-ansi-basic.png)

You can also view foreground and or background settings.

![show ansi foreground](images/show-ansi-foreground.png)

You can even use an RGB value.

![show ansi rgb sequence](images/show-ansi-rgb.png)

The escape character will match what is acceptable in your version of PowerShell. These screen shots are showing PowerShell 7.

## Other Module Features

From time to time, I will include additional items that you might find useful in your PowerShell work.
Expand Down
45 changes: 9 additions & 36 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

This file contains the most recent change history for the PSScriptTools module.

## v2.42.0

+ Updated module manifest to load required .NET assembly for `Convert-HTMLtoAnsi`. [Issue #124](https://github.com/jdhitsolutions/PSScriptTools/issues/124)
+ Updated `Show-AnsiSequence` to fix a display bug that was dropping values. [Issue #125](https://github.com/jdhitsolutions/PSScriptTools/issues/125)
+ Updated missing online help links.
+ Added new sample script `today.ps1`.
+ Help updates.
+ Updated `README.md`.

## v2.41.0

+ Added function `Copy-CommandHistory` with an alias of `ch`.
Expand All @@ -21,42 +30,6 @@ This file contains the most recent change history for the PSScriptTools module.
+ Modified `Convertto-Markdown` to add a `AsList` parameter. [Issue #114](https://github.com/jdhitsolutions/PSScriptTools/issues/114)
+ Updated `README.md`.

## v2.39.0

+ Updated `Test-WithCulture` to include additional Verbose output.
+ Added command [Get-FileExtensionInfo](docs/Get-FileExtensionInfo.md) with format file `FileExtensionInfo.format.ps1xml'. This command will require PowerShell 7.
+ Added `New-PSDynamicParameter` and `New-PSDynamicParameterForm`.
+ Incorporated pull request [#116](https://github.com/jdhitsolutions/PSScriptTools/pull/116) to fix bug with `Get-ParameterInfo` when the command has a `count` parameter. Thanks @ninmonkey.
+ Added command [Get-LastModifiedFile](docs/Get-LastModifiedFile.md) and its alias *glm*.
+ Help updates.
+ Updated `README.md`.

## v2.38.0

+ Added `Get-PSUnique` function with an alias of `gpsu`. ([Issue #109](https://github.com/jdhitsolutions/PSScriptTools/issues/109)).
+ Modified `Show-AnsiSequence` to default to `Foreground` when using `-Type` ([Issue #110](https://github.com/jdhitsolutions/PSScriptTools/issues/110)).
+ Cleaned up module manifest.
+ Updated `New-PSFormatXML` to __not__ create the ps1xml file if a bad property is detected ([Issue #111](https://github.com/jdhitsolutions/PSScriptTools/issues/111)).
+ Modified `New-PSFormatXML` to __not__ add an explicit declaration. This means the files will now be saved in the correct UTF-8 format and not UTF-8 with BOM.
+ Modified TODO VSCode command to put date at the end. Otherwise, it breaks the `Better Comments` extension.
+ Added `Set-LocationToFile` which is only loaded when importing the module in VS Code or the PowerShell ISE.
+ Re-saved all `.ps1xml` files as `UTF-8`.
+ Added custom type extension files `fileinfo.types.ps1xml` and `system.diagnostics.process.types.ps1xml`.
+ Updated `README.md`.

## v2.37.0

+ Updated `Convertto-WPFGrid` to better handle non-standard property names. ([Issue #108](https://github.com/jdhitsolutions/PSScriptTools/issues/108)).
+ Modified custom format files that use ANSI to test if host name matches 'console' or 'code' to support VSCode.
+ Modified `Summary` view in `psparameterinfo.format.ps1xml` to not use autosizing.
+ Added `<AutoSize/>` back to `serviceansi.format.ps1xml` so that ANSI output displays properly.
+ Modified `Show-ANSI` and `Get-PSAnsiFileMap` to use `[char]27` instead of `[char]0x1b` for Windows PowerShell sessions.
+ Modified ANSI sequences in format files to use `[char]27`. ([Issue #107](https://github.com/jdhitsolutions/PSScriptTools/issues/107)).
+ Modified ANSI sequences in format files recognize a remote PSSession. ([Issue #106](https://github.com/jdhitsolutions/PSScriptTools/issues/106)).
+ Update `Get-PSLocation` to work in a PowerShell remoting session where there is no profile. ([Issue #104](https://github.com/jdhitsolutions/PSScriptTools/issues/104)).
+ Updated help.
+ Updated `README.md`.

## Archive

If you need to see older change history, look at the [Archive ChangeLog](https://github.com/jdhitsolutions/PSScriptTools/blob/master/Archive-ChangeLog.md) online.
2 changes: 1 addition & 1 deletion docs/Copy-HistoryCommand.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: https://bit.ly/3nPKjwX
schema: 2.0.0
---

Expand Down
2 changes: 2 additions & 0 deletions docs/New-ANSIBar.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,5 @@ Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell
[New-RedGreenGradient](New-RedGreenGradient.md)
[Write-ANSIProgress](Write-ANSIProgress.md)
[Show-ANSISequence](Show-ANSISequence.md)
17 changes: 13 additions & 4 deletions docs/Show-ANSISequence.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: https://en.wikipedia.org/wiki/ANSI_escape_code
online version: https://bit.ly/3Ix5s77
schema: 2.0.0
---

Expand Down Expand Up @@ -63,7 +63,7 @@ The output will be formatted using the corresponding ANSI escape sequence as see
### EXAMPLE 2

```powershell
PS C:\>Show-ANSISequence -Foreground -Type Simple
PS C:\> Show-ANSISequence -Foreground -Type simple
**************
* Foreground *
Expand All @@ -73,6 +73,7 @@ PS C:\>Show-ANSISequence -Foreground -Type Simple
`e[34mHello`e[0m `e[35mHello`e[0m `e[36mHello`e[0m
`e[90mHello`e[0m `e[91mHello`e[0m `e[92mHello`e[0m
`e[94mHello`e[0m `e[95mHello`e[0m `e[96mHello`e[0m
```

### EXAMPLE 3
Expand All @@ -91,7 +92,7 @@ Show an RGB ANSI sequence. The output will be formatted using the sequence.
PS C:\> Show-ANSISequence -RGB 225,100,50 -AsString | Set-Clipboard
```

Repeat the previous example but write the output as a plain string and copy it to the Windows clipboard.
Repeat the previous example but write the output as a plain string and copy it to the clipboard.

## PARAMETERS

Expand Down Expand Up @@ -205,6 +206,14 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
### System.String
## Notes
Learn more about ANSI sequences at https://en.wikipedia.org/wiki/ANSI_escape_code
Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/
## RELATED LINKS
[https://en.wikipedia.org/wiki/ANSI_escape_code](https://en.wikipedia.org/wiki/ANSI_escape_code)
[Write-ANSIProgress](Write-ANSIProgress.md)
[New-ANSIBar](New-ANSIBar.md)
4 changes: 3 additions & 1 deletion docs/Write-ANSIProgress.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ PS C:\> $sb = {
@{Name="Size";Expression={$_.Sum}}
}
Write-Host ""
$out | Sort-object -property Size -Descending
$out | Sort-Object -property Size -Descending
}
PS C:\> Invoke-Command -scriptblock $sb
```
Expand Down Expand Up @@ -185,3 +185,5 @@ Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell
[New-ANSIBar](New-ANSIBar.md)
[New-RedGreenGradient](New-RedGreenGradient.md)
[Show-ANSISequence](Show-ANSISequence.md)
35 changes: 29 additions & 6 deletions en-us/PSScriptTools-help.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4162,6 +4162,10 @@ Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id SI ProcessName
</command:example>
</command:examples>
<command:relatedLinks>
<maml:navigationLink>
<maml:linkText>Online Version:</maml:linkText>
<maml:uri>https://bit.ly/3nPKjwX</maml:uri>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Get-History</maml:linkText>
<maml:uri></maml:uri>
Expand Down Expand Up @@ -10836,6 +10840,10 @@ Count 3</dev:code>
<maml:linkText>Write-ANSIProgress</maml:linkText>
<maml:uri></maml:uri>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Show-ANSISequence</maml:linkText>
<maml:uri></maml:uri>
</maml:navigationLink>
</command:relatedLinks>
</command:command>
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp">
Expand Down Expand Up @@ -17458,7 +17466,10 @@ PS C:\Scripts\Foo\&gt;</dev:code>
</command:returnValue>
</command:returnValues>
<maml:alertSet>
<maml:alert />
<maml:alert>
<maml:para>Learn more about ANSI sequences at https://en.wikipedia.org/wiki/ANSI_escape_code</maml:para>
<maml:para>Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/</maml:para>
</maml:alert>
</maml:alertSet>
<command:examples>
<command:example>
Expand All @@ -17482,7 +17493,7 @@ PS C:\Scripts\Foo\&gt;</dev:code>
</command:example>
<command:example>
<maml:title>-------------------------- EXAMPLE 2 --------------------------</maml:title>
<dev:code>PS C:\&gt;Show-ANSISequence -Foreground -Type Simple
<dev:code>PS C:\&gt; Show-ANSISequence -Foreground -Type simple

**************
* Foreground *
Expand All @@ -17509,14 +17520,22 @@ PS C:\Scripts\Foo\&gt;</dev:code>
<maml:title>-------------------------- EXAMPLE 4 --------------------------</maml:title>
<dev:code>PS C:\&gt; Show-ANSISequence -RGB 225,100,50 -AsString | Set-Clipboard</dev:code>
<dev:remarks>
<maml:para>Repeat the previous example but write the output as a plain string and copy it to the Windows clipboard.</maml:para>
<maml:para>Repeat the previous example but write the output as a plain string and copy it to the clipboard.</maml:para>
</dev:remarks>
</command:example>
</command:examples>
<command:relatedLinks>
<maml:navigationLink>
<maml:linkText>https://en.wikipedia.org/wiki/ANSI_escape_code</maml:linkText>
<maml:uri>https://en.wikipedia.org/wiki/ANSI_escape_code</maml:uri>
<maml:linkText>Online Version:</maml:linkText>
<maml:uri>https://bit.ly/3Ix5s77</maml:uri>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Write-ANSIProgress</maml:linkText>
<maml:uri></maml:uri>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>New-ANSIBar</maml:linkText>
<maml:uri></maml:uri>
</maml:navigationLink>
</command:relatedLinks>
</command:command>
Expand Down Expand Up @@ -19408,7 +19427,7 @@ BOVINE320 32 12 37.87% ■■■■■■■■■■■■■
@{Name="Size";Expression={$_.Sum}}
}
Write-Host ""
$out | Sort-object -property Size -Descending
$out | Sort-Object -property Size -Descending
}
PS C:\&gt; Invoke-Command -scriptblock $sb</dev:code>
<dev:remarks>
Expand All @@ -19429,6 +19448,10 @@ PS C:\&gt; Invoke-Command -scriptblock $sb</dev:code>
<maml:linkText>New-RedGreenGradient</maml:linkText>
<maml:uri></maml:uri>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Show-ANSISequence</maml:linkText>
<maml:uri></maml:uri>
</maml:navigationLink>
</command:relatedLinks>
</command:command>
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp">
Expand Down
Loading

0 comments on commit de6891a

Please sign in to comment.