Skip to content

Commit d38aba9

Browse files
v2.40.0
1 parent ef4f387 commit d38aba9

21 files changed

+651
-109
lines changed

Archive-ChangeLog.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,31 @@
22

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

5+
## v2.36.0
6+
7+
+ 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.
8+
+ Added table view called `Simple` to format file for Aliases.
9+
+ Modified `Options` table view in `alias.format.ps1xml` to highlight read-only aliases in Red using ANSI if running in a PowerShell console host.
10+
+ Updated `Get-PSLocation` to include `$PSHome`.
11+
+ Modified module to only dot source `Get-MyCounter.ps1` if running Windows. The file contains a class definition that uses a Windows-only reference and PowerShell "scans" the file before it dot sources it, which throws an exception on non-Windows platforms.
12+
+ Added command `Get-PSSessionInfo` and an alias of `gsin`. The command uses a new format file, `pssessioninfo.format.ps1xml`.
13+
+ Added command `Test-IsElevated`.
14+
+ Updated `Get-PSWho` to included elevated information for non-Windows platforms.
15+
+ Added format file `pswho.format.ps1xml`.
16+
+ Help updates
17+
+ Updated `README.md`.
18+
19+
## v2.35.0
20+
21+
+ Added `ConvertTo-TitleCase` command with aliases of `totc` and `title`.
22+
+ Added `New-FunctionItem` command with an alias of `nfi` to create functions on-the-fly.
23+
+ Added `Show-FunctionItem` command with an alias of `sfi` to display a function.
24+
+ Modified format files to test the console when using ANSI formatting. ([Issue #102](https://github.com/jdhitsolutions/PSScriptTools/issues/102))
25+
+ Modified ANSI functions to display a warning when run in the PowerShell ISE and exit.
26+
+ Updated `Get-PSScriptTools` to not use ANSI in the header when running in a non-console host.
27+
+ Updated `Get-CommandSyntax` to not use ANSI formatting when running in a non-console host.
28+
+ Updated `README.md`.
29+
530
## v2.34.1
631

732
+ Updated `license.txt` with the new year.

PSScriptTools.psd1

-144 Bytes
Binary file not shown.

PSScriptToolsManual.pdf

133 KB
Binary file not shown.

README.md

Lines changed: 65 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@ which generates this markdown:
827827
```markdown
828828
# Service Check
829829

830-
## BOVINE320
830+
## THINKX1
831831

832832
```dos
833833

@@ -837,9 +837,57 @@ which generates this markdown:
837837
Running Winrm Windows Remote Management (WS-Manag...
838838
```
839839

840-
_report 09/25/2019 09:57:12_
840+
_report 09/25/2021 09:57:12_
841841
```
842842

843+
You also have the option to format the output as a markdown table.
844+
845+
```powershell
846+
ConvertTo-Markdown -title "OS Summary" -PreContent "## $($env:computername)" -postcontent "_Confidential_" -AsTable
847+
```
848+
849+
Which creates this markdown output.
850+
851+
```markdown
852+
# OS Summary
853+
854+
## THINKX1-JH
855+
856+
| ProductName | EditionID | ReleaseID | Build | Branch | InstalledUTC | Computername |
857+
| ----------- | --------- | --------- | ----- | ------ | ------------ | ------------ |
858+
| Windows 10 Pro | Professional | 2009 | 22000.376 | co_release | 08/10/2021 00:17:07 | THINKX1-JH |
859+
860+
_Confidential_
861+
```
862+
863+
![convertto-markdown table](images/convert-markdown-table.png)
864+
865+
Or you can create a list table with the property name in one columen and the value in the second column.
866+
867+
```powershell
868+
Get-WindowsVersion | ConvertTo-Markdown -title "OS Summary" -PreContent "## $($env:computername)" -postcontent "_Confidential_" -AsList
869+
```
870+
871+
```markdown
872+
# OS Summary
873+
874+
## THINKX1-JH
875+
876+
| | |
877+
|----|----|
878+
|ProductName|Windows 10 Pro|
879+
|EditionID|Professional|
880+
|ReleaseID|2009|
881+
|Build|22000.376|
882+
|Branch|co_release|
883+
|InstalledUTC|8/10/2021 12:17:07 AM|
884+
|Computername|THINKX1-JH|
885+
886+
_Confidential_
887+
```
888+
889+
![convertto-markdown list](images/convert-markdown-list.png)
890+
843891
Because the function writes markdown to the pipeline you will need to pipe it to a command `Out-File` to create a file.
844892

845893
## Editor Integrations
@@ -2368,6 +2416,21 @@ Remove-PSAnsiFileEntry DevFiles
23682416

23692417
Any changes you make to `$PSAnsiFileMap` will only last until you import the module again. To make the change permanent, use [Export-PSAnsiFileMap](docs/Export-PSAnsiFileMap.md). This will create the `psansifilemap.json` file in your `$HOME` directory. When you import the PSSCriptTools module, if this file is found, it will be imported. Otherwise, the default module file will be used.
23702418

2419+
### [Convert-HtmlToAnsi](docs/Convert-HtmlToAnsi.md)
2420+
2421+
This simple function is designed to convert an HTML color code like #ff5733 into an ANSI escape sequence.
2422+
2423+
```text
2424+
PS C:\> Convert-HtmlToAnsi "#ff5733"
2425+
[38;2;255;87;51m
2426+
```
2427+
2428+
To use the resulting value you still need to construct an ANSI string with the escape character and the closing [0m.
2429+
2430+
![convert html to ansi](images/convert-htmltoansi.png)
2431+
2432+
In PowerShell 7 you can use `` `e ``. Or `$([char]27)` which works in all PowerShell versions.
2433+
23712434
## Other Module Features
23722435

23732436
From time to time, I will include additional items that you might find useful in your PowerShell work.

changelog.md

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

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

5+
## v2.40.0
6+
7+
+ Updated parameter validation for IP address in `Get-WhoIs` to allow addresses with 255 in an octet. [Issue #117](https://github.com/jdhitsolutions/PSScriptTools/issues/117).
8+
+ Updated help files with missing online links.
9+
+ Added command `Convert-HtmlToAnsi` with an alias of `cha`.
10+
+ Modified `Convertto-Markdown` to add a `AsList` parameter. [Issue #114](https://github.com/jdhitsolutions/PSScriptTools/issues/114)
11+
+ Updated `README.md`.
12+
513
## v2.39.0
614

715
+ Updated `Test-WithCulture` to include additional Verbose output.
@@ -38,32 +46,6 @@ This file contains the most recent change history for the PSScriptTools module.
3846
+ Updated help.
3947
+ Updated `README.md`.
4048

41-
## v2.36.0
42-
43-
+ 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.
44-
+ Added table view called `Simple` to format file for Aliases.
45-
+ Modified `Options` table view in `alias.format.ps1xml` to highlight read-only aliases in Red using ANSI if running in a PowerShell console host.
46-
+ Updated `Get-PSLocation` to include `$PSHome`.
47-
+ Modified module to only dot source `Get-MyCounter.ps1` if running Windows. The file contains a class definition that uses a Windows-only reference and PowerShell "scans" the file before it dot sources it, which throws an exception on non-Windows platforms.
48-
+ Added command `Get-PSSessionInfo` and an alias of `gsin`. The command uses a new format file, `pssessioninfo.format.ps1xml`.
49-
+ Added command `Test-IsElevated`.
50-
+ Updated `Get-PSWho` to included elevated information for non-Windows platforms.
51-
+ Added format file `pswho.format.ps1xml`.
52-
+ Help updates
53-
+ Updated `README.md`.
54-
55-
## v2.35.0
56-
57-
+ Added `ConvertTo-TitleCase` command with aliases of `totc` and `title`.
58-
+ Added `New-FunctionItem` command with an alias of `nfi` to create functions on-the-fly.
59-
+ Added `Show-FunctionItem` command with an alias of `sfi` to display a function.
60-
+ Modified format files to test the console when using ANSI formatting. ([Issue #102](https://github.com/jdhitsolutions/PSScriptTools/issues/102))
61-
+ Modified ANSI functions to display a warning when run in the PowerShell ISE and exit.
62-
+ Updated `Get-PSScriptTools` to not use ANSI in the header when running in a non-console host.
63-
+ Updated `Get-CommandSyntax` to not use ANSI formatting when running in a non-console host.
64-
+ Updated `README.md`.
65-
66-
6749
## Archive
6850

6951
If you need to see older change history, look at the [Archive ChangeLog](https://github.com/jdhitsolutions/PSScriptTools/blob/master/Archive-ChangeLog.md) online.

docs/Convert-HtmlToAnsi.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
---
2+
external help file: PSScriptTools-help.xml
3+
Module Name: PSScriptTools
4+
online version:
5+
schema: 2.0.0
6+
---
7+
8+
# Convert-HtmlToAnsi
9+
10+
## SYNOPSIS
11+
12+
Convert an HTML color code to ANSI.
13+
14+
## SYNTAX
15+
16+
```yaml
17+
Convert-HtmlToAnsi [-HtmlCode] <String> [<CommonParameters>]
18+
```
19+
20+
## DESCRIPTION
21+
22+
This simple function is designed to convert an HTML color code like #ff5733 into an ANSI escape sequence. To use the resulting value you still need to construct an ANSI string with the escape character and the closing [0m.
23+
24+
## EXAMPLES
25+
26+
### Example 1
27+
28+
```powershell
29+
PS C:\> Convert-HtmlToAnsi "#ff5733"
30+
31+
[38;2;255;87;51m
32+
```
33+
34+
### Example 2
35+
36+
```powershell
37+
PS C:\> "Running processes: `e$(cha "#ff337d")$((Get-Process).count)`e[0m"
38+
39+
Running processes: 306
40+
```
41+
42+
The number of processes will be displayed in color. This example is using the cha alias for Convert-HtmlToAnsi.
43+
44+
## PARAMETERS
45+
46+
### -HtmlCode
47+
48+
Specify an HTML color code like #13A10E. You need to include the # character.
49+
50+
```yaml
51+
Type: String
52+
Parameter Sets: (All)
53+
Aliases: code
54+
55+
Required: True
56+
Position: 0
57+
Default value: None
58+
Accept pipeline input: True (ByValue)
59+
Accept wildcard characters: False
60+
```
61+
62+
### CommonParameters
63+
64+
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).
65+
66+
## INPUTS
67+
68+
### System.String
69+
70+
## OUTPUTS
71+
72+
### System.String
73+
74+
## NOTES
75+
76+
Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/
77+
78+
## RELATED LINKS

docs/ConvertTo-Markdown.md

Lines changed: 78 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,30 @@ Convert pipeline output to a markdown document.
1313

1414
## SYNTAX
1515

16+
### text (Default)
17+
1618
```yaml
1719
ConvertTo-Markdown [[-Inputobject] <Object>] [-Title <String>]
18-
[-PreContent <String[]>] [-PostContent <String[]>] [-Width <Int32>] [-AsTable]
19-
[<CommonParameters>]
20+
[-PreContent <String[]>] [-PostContent <String[]>] [-Width <Int32>] [<CommonParameters>]
21+
```
22+
23+
### table
24+
25+
```yaml
26+
ConvertTo-Markdown [[-Inputobject] <Object>] [-Title <String>] [-PreContent <String[]>] [-PostContent <String[]>] [-AsTable] [<CommonParameters>]
27+
```
28+
29+
### list
30+
31+
```yaml
32+
ConvertTo-Markdown [[-Inputobject] <Object>] [-Title <String>] [-PreContent <String[]>] [-PostContent <String[]>] [-AsList] [<CommonParameters>]
2033
```
2134

2235
## DESCRIPTION
2336

24-
This command is designed to accept pipelined output and create a generic markdown document. The pipeline output will formatted as a text block or you can specify a table. You can optionally define a title, content to appear before the output, and content to appear after the output. Best efforts have been made to produce markdown output that meets basic standards.
37+
This command is designed to accept pipelined output and create a generic markdown document. The pipeline output will formatted as a text block or you can specify a table. The AsList parameter technically still create a table, but it is two columns with the property namd and value.
38+
39+
You can optionally define a title, content to appear before the output, and content to appear after the output. Best efforts have been made to produce markdown output that meets basic standards.
2540

2641
The command does not create a text file. You need to pipe results from this command to a cmdlet like Out-File or Set-Content. See examples.
2742

@@ -84,7 +99,46 @@ PS C:\>$out += ConvertTo-Markdown -PostContent $footer
8499
PS C:\>$out | Set-Content c:\work\report.md
85100
```
86101

87-
Here is an example that creates a series of markdown fragments for each computer and in the end creates a markdown document.
102+
Here is an example that creates a series of markdown fragments for each computer and in the end creates a markdown document. The commands are shown at a PowerShell prompt, but you are likely to put them in a PowerShell script file.
103+
104+
### EXAMPLE 4
105+
106+
```powershell
107+
PS C:\> Get-WindowsVersion | ConvertTo-Markdown -title "OS Summary" -PreContent "## $($env:computername)" -AsList
108+
# OS Summary
109+
110+
## THINKX1
111+
112+
| | |
113+
|----|----|
114+
|ProductName|Windows 10 Pro|
115+
|EditionID|Professional|
116+
|ReleaseID|2009|
117+
|Build|22000.376|
118+
|Branch|co_release|
119+
|InstalledUTC|8/10/2021 12:17:07 AM|
120+
|Computername|THINKX1-JH|
121+
```
122+
123+
Create a "list" table with output from the Get-WindowsVersion command.
124+
125+
### EXAMPLE 5
126+
127+
```powershell
128+
PS C:\> Get-Service | Sort-Object -property Displayname |
129+
Foreach-Object -begin {
130+
"# Service Status`n"
131+
} -process {
132+
$name = $_.Displayname
133+
$_ | Select-Object -property Name,StartType,Status,
134+
@{Name="RequiredServices";Expression = {$_.requiredservices.name -join ','}} |
135+
ConvertTo-Markdown -asList -PreContent "## $Name"
136+
} -end {
137+
"### $($env:computername) $(Get-Date)"
138+
} | Out-File c:\work\services.md
139+
```
140+
141+
The example will create a markdown file with a title of Service Status. Each service will be converted to a markdown list with the DisplayName as pre-content.
88142

89143
## PARAMETERS
90144

@@ -106,7 +160,7 @@ Accept wildcard characters: False
106160
107161
### -Title
108162
109-
Specify a top-level title. You do not need to include any markdown.
163+
Specify a top-level title. You do not need to include any markdown. It will automatically be formatted with a H1 tag.
110164
111165
```yaml
112166
Type: String
@@ -158,7 +212,7 @@ Specify the document width. Depending on what you intend to do with the markdown
158212
159213
```yaml
160214
Type: Int32
161-
Parameter Sets: (All)
215+
Parameter Sets: text
162216
Aliases:
163217

164218
Required: False
@@ -175,8 +229,24 @@ This works best with similar content such as the result of running a PowerShell
175229
176230
```yaml
177231
Type: SwitchParameter
178-
Parameter Sets: (All)
179-
Aliases:
232+
Parameter Sets: table
233+
Aliases: table
234+
235+
Required: False
236+
Position: Named
237+
Default value: None
238+
Accept pipeline input: False
239+
Accept wildcard characters: False
240+
```
241+
242+
### -AsList
243+
244+
Display results as a 2 column markdown table. The first column will be the property name with the value formatted as a string in the second column.
245+
246+
```yaml
247+
Type: SwitchParameter
248+
Parameter Sets: list
249+
Aliases: list
180250

181251
Required: False
182252
Position: Named

docs/Get-FileExtensionInfo.md

Lines changed: 1 addition & 1 deletion
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: https://bit.ly/3f50Wjs
55
schema: 2.0.0
66
---
77

docs/Get-LastModifiedFile.md

Lines changed: 1 addition & 1 deletion
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: https://bit.ly/3FbzOu3
55
schema: 2.0.0
66
---
77

0 commit comments

Comments
 (0)