Skip to content

Commit f180fa8

Browse files
v2.25.0
1 parent 37833f9 commit f180fa8

11 files changed

+147
-55
lines changed

PSScriptTools.psd1

0 Bytes
Binary file not shown.

PSScriptTools.psm1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ $global:PSSpecialChar = @{
4646
Club = ([char]0x2663)
4747
Heart = ([char]0x2665)
4848
Spade = ([char]0x2660)
49+
Section = ([char]0x00A7)
50+
RightPointer = ([char]0x25BA)
51+
LeftPointer = ([char]0x25C4)
52+
BlackRectangle = ([char]0x25CA)
4953
}
5054

5155
Write-Verbose "Defining the variable `$PSSamplePath to the samples folder for this module"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1571,4 +1571,4 @@ If you find this module useful, you might also want to look at my tools for [cre
15711571

15721572
Where possible these commands have been tested with PowerShell 7, but not every platform. If you encounter problems, have suggestions or other feedback, please post an [issue](https://github.com/jdhitsolutions/PSScriptTools/issues). It is assumed you will __not__ be running this commands on any edition of PowerShell Core or any beta releases of PowerShell 7.
15731573

1574-
> Last Updated *2020-05-21 20:11:54Z UTC*
1574+
> Last Updated *2020-05-29 13:36:08Z UTC*

changelog.md

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

3+
## v2.25.0
4+
5+
### Add
6+
7+
+ Added a set of ANSI mappings for temporary files and system files in `psansifilemap.json`.
8+
+ Added additional file extensions to `psansifilemap.json`.
9+
+ Added pointers, section sign, and black rectangle to PSSpecialChars hashtable.
10+
11+
### Change
12+
13+
+ Modified `Show-Tree` to make the `InColor` parameter always available. (Issue #80)
14+
+ Modified `Add-Border` to use ANSI escape codes that will work in both Windows PowerShell and PowerShell 7.
15+
+ Updated `New-PSFormatXML` to better handle empty or null property values. (Issue #81)
16+
+ Help Updates
17+
18+
### Delete
19+
20+
+ None
21+
322
## v2.24.0
423

524
### Add

docs/New-PSFormatXML.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ New-PSFormatXML [-InputObject] <Object> [[-Properties] <String[]>] [-Typename <S
2323

2424
When defining custom objects with a new typename, PowerShell by default will display all properties. However, you may wish to have a specific default view, be it a table or list. Or you may want to have different views display the object differently. Format directives are stored in format.ps1xml files which can be tedious to create. This command simplifies that process.
2525

26-
Pipe an instance of your custom object to this function and it will generate a format.ps1xml file based on either all the properties or a subset that you provide. When creating the file make sure the object you are modeling with does not have empty property values. You can repeat the process to add additional views. When finished, edit the format.ps1xml file and fine tune it. The file will have notes on how to substitute script blocks. If you run this command inside the Visual Studio Code PowerShell Integrated Console and use -Passthru, the new file will automatically be opened in your editor.
26+
Pipe an instance of your custom object to this function and it will generate a format.ps1xml file based on either all the properties or a subset that you provide. You can repeat the process to add additional views. When finished, edit the format.ps1xml file and fine tune it. The file will have notes on how to substitute script blocks. If you run this command inside the Visual Studio Code PowerShell Integrated Console and use -Passthru, the new file will automatically be opened in your editor.
2727

28-
Note that table views are set to Autosize. But the table definition will include best guesses for column widths. If you prefer a more granular approach you can delete the Autosize tag and experiment with varying widths. Don't forget to run Update-FormatData to load your new file. You may need to start a new PowerShell session to test changes.
28+
Note that table views are set to Autosize. But the table definition will include best guesses for column widths. If you prefer a more granular approach you can delete the Autosize tag and experiment with varying widths. Don't forget to run Update-FormatData to load your new file. You may need to start a new PowerShell session to fully test changes.
2929

3030
## EXAMPLES
3131

@@ -119,6 +119,14 @@ Once loaded into PowerShell, you can run a command like this:
119119

120120
Get-Service | Sort-Object Status | Format-Wide -view Status
121121

122+
### Example 6
123+
124+
```powershell
125+
PS C:\> '' | Select-Object -Property Name,Size,Date,Count,Age | New-PSFormatXML -Typename myThing -Path c:\scripts\mything.format.ps1xml
126+
```
127+
128+
This is an example of creating a formatting file from an empty object. Normally you would first define your object and verify it has all the properties you need and then you would create the formatting file. But you may want to create the formatting file in parallel using a technique like this.
129+
122130
## PARAMETERS
123131

124132
### -Append
@@ -172,7 +180,7 @@ Accept wildcard characters: False
172180
173181
### -InputObject
174182
175-
Specify an object to analyze and generate or update a ps1xml file. All you need is one instance of the object.
183+
Specify an object to analyze and generate or update a ps1xml file. All you need is one instance of the object. Ideally, the object will have values for all properties.
176184
177185
```yaml
178186
Type: Object

docs/Show-Tree.md

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,23 @@ Shows the specified path as a tree.
1717

1818
```yaml
1919
Show-Tree [[-Path] <String[]>] [[-Depth] <Int32>] [-IndentSize <Int32>] [-ShowItem] [-ShowProperty <String[]>]
20-
[<CommonParameters>]
20+
[-InColor] [<CommonParameters>]
2121
```
2222

2323
### LiteralPath
2424

2525
```yaml
2626
Show-Tree [[-LiteralPath] <String[]>] [[-Depth] <Int32>] [-IndentSize <Int32>] [-ShowItem]
27-
[-ShowProperty <String[]>] [<CommonParameters>]
27+
[-ShowProperty <String[]>] [-InColor] [<CommonParameters>]
2828
```
2929

3030
## DESCRIPTION
3131

32-
Shows the specified path as a graphical tree in the console. This is intended as PowerShell alternative to the tree DOS command. This function should work for any type of PowerShell provider and can be used to explore providers used for configuration like the WSMan provider or the registry. Currently, this will not work with any PSDrives created with the Certificate provider.
32+
Shows the specified path as a graphical tree in the console. This is intended as PowerShell alternative to the tree DOS command. This function should work for any type of PowerShell provider and can be used to explore providers used for configuration like the WSMan provider or the registry. Currently, this will *not work* with any PSDrives created with the Certificate provider. It should work cross-platform.
3333

3434
By default, the output will only show directory or equivalent structures. But you can opt to include items well as item details by using the ShowProperty parameter. Specify a comma separated list of properties or use * to view them all.
3535

36-
It should work cross-platform. If you are running PowerShell 7, there is a dynamic parameter, -InColor, that will write ANSI-colored output to the pipeline. The color scheme is designed for the file system. This parameter has an alias of -ansi.
36+
If the Path is a FileSystem path there is a dynamic parameter, -InColor, that will write ANSI-colored output to the pipeline. This parameter has an alias of -ansi.
3737

3838
Note: This is an update to an older function in my library. I seem to recall I found the original code somewhere online, perhaps from someone like Lee Holmes. Sadly, I neglected to record the source.
3939

@@ -125,7 +125,7 @@ Shows all the containers and items in the WSMan: drive.
125125
### Example 4
126126

127127
```powershell
128-
PS C:\> pstree c:\work\alpha -files -properties LastWriteTime,Length
128+
PS C:\> pstree c:\work\alpha -files -properties LastWriteTime,Length -ansi
129129
130130
C:\work\Alpha\
131131
+-- LastWriteTime = 02/28/2020 11:19:32
@@ -152,7 +152,7 @@ C:\work\Alpha\
152152
...
153153
```
154154

155-
Show a tree listing with files including a few user specified properties. This example is using parameter and command aliases.
155+
Show a tree listing with files including a few user specified properties in color. This example is using parameter and command aliases.
156156

157157
## PARAMETERS
158158

@@ -238,8 +238,7 @@ Accept wildcard characters: False
238238
239239
### -ShowProperty
240240
241-
Shows the properties on containers and items.
242-
Use * to display all properties otherwise specify a comma separated list.
241+
Shows the properties on containers and items. Use * to display all properties otherwise specify a comma separated list.
243242
244243
```yaml
245244
Type: String[]
@@ -253,6 +252,22 @@ Accept pipeline input: False
253252
Accept wildcard characters: False
254253
```
255254
255+
### -InColor
256+
257+
Show tree and item colorized. Values are from the $PSAnsiMap variable.
258+
259+
```yaml
260+
Type: SwitchParameter
261+
Parameter Sets: (All)
262+
Aliases: ansi
263+
264+
Required: False
265+
Position: Named
266+
Default value: None
267+
Accept pipeline input: False
268+
Accept wildcard characters: False
269+
```
270+
256271
### CommonParameters
257272
258273
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).
@@ -267,8 +282,6 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
267282
268283
## NOTES
269284
270-
If you are using PowerShell 7, you can use the InColor parameter, or its alias ansi, to display the tree in a color code format.
271-
272285
Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/
273286
274287
## RELATED LINKS

en-us/PSScriptTools-help.xml

Lines changed: 49 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8172,16 +8172,16 @@ PS DeepDive:\&gt;</dev:code>
81728172
</command:details>
81738173
<maml:description>
81748174
<maml:para>When defining custom objects with a new typename, PowerShell by default will display all properties. However, you may wish to have a specific default view, be it a table or list. Or you may want to have different views display the object differently. Format directives are stored in format.ps1xml files which can be tedious to create. This command simplifies that process.</maml:para>
8175-
<maml:para>Pipe an instance of your custom object to this function and it will generate a format.ps1xml file based on either all the properties or a subset that you provide. When creating the file make sure the object you are modeling with does not have empty property values. You can repeat the process to add additional views. When finished, edit the format.ps1xml file and fine tune it. The file will have notes on how to substitute script blocks. If you run this command inside the Visual Studio Code PowerShell Integrated Console and use -Passthru, the new file will automatically be opened in your editor.</maml:para>
8176-
<maml:para>Note that table views are set to Autosize. But the table definition will include best guesses for column widths. If you prefer a more granular approach you can delete the Autosize tag and experiment with varying widths. Don't forget to run Update-FormatData to load your new file. You may need to start a new PowerShell session to test changes.</maml:para>
8175+
<maml:para>Pipe an instance of your custom object to this function and it will generate a format.ps1xml file based on either all the properties or a subset that you provide. You can repeat the process to add additional views. When finished, edit the format.ps1xml file and fine tune it. The file will have notes on how to substitute script blocks. If you run this command inside the Visual Studio Code PowerShell Integrated Console and use -Passthru, the new file will automatically be opened in your editor.</maml:para>
8176+
<maml:para>Note that table views are set to Autosize. But the table definition will include best guesses for column widths. If you prefer a more granular approach you can delete the Autosize tag and experiment with varying widths. Don't forget to run Update-FormatData to load your new file. You may need to start a new PowerShell session to fully test changes.</maml:para>
81778177
</maml:description>
81788178
<command:syntax>
81798179
<command:syntaxItem>
81808180
<maml:name>New-PSFormatXML</maml:name>
81818181
<command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="0" aliases="none">
81828182
<maml:name>InputObject</maml:name>
81838183
<maml:Description>
8184-
<maml:para>Specify an object to analyze and generate or update a ps1xml file. All you need is one instance of the object.</maml:para>
8184+
<maml:para>Specify an object to analyze and generate or update a ps1xml file. All you need is one instance of the object. Ideally, the object will have values for all properties.</maml:para>
81858185
</maml:Description>
81868186
<command:parameterValue required="true" variableLength="false">Object</command:parameterValue>
81878187
<dev:type>
@@ -8364,7 +8364,7 @@ PS DeepDive:\&gt;</dev:code>
83648364
<command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="0" aliases="none">
83658365
<maml:name>InputObject</maml:name>
83668366
<maml:Description>
8367-
<maml:para>Specify an object to analyze and generate or update a ps1xml file. All you need is one instance of the object.</maml:para>
8367+
<maml:para>Specify an object to analyze and generate or update a ps1xml file. All you need is one instance of the object. Ideally, the object will have values for all properties.</maml:para>
83688368
</maml:Description>
83698369
<command:parameterValue required="true" variableLength="false">Object</command:parameterValue>
83708370
<dev:type>
@@ -8586,6 +8586,13 @@ Jeff 2/10/2019 8:49:10 AM Microsoft Windows 10 Pro 40.20:56:24.5411481</dev:code
85868586
<maml:para>Get-Service | Sort-Object Status | Format-Wide -view Status</maml:para>
85878587
</dev:remarks>
85888588
</command:example>
8589+
<command:example>
8590+
<maml:title>-------------------------- Example 6 --------------------------</maml:title>
8591+
<dev:code>PS C:\&gt; '' | Select-Object -Property Name,Size,Date,Count,Age | New-PSFormatXML -Typename myThing -Path c:\scripts\mything.format.ps1xml</dev:code>
8592+
<dev:remarks>
8593+
<maml:para>This is an example of creating a formatting file from an empty object. Normally you would first define your object and verify it has all the properties you need and then you would create the formatting file. But you may want to create the formatting file in parallel using a technique like this.</maml:para>
8594+
</dev:remarks>
8595+
</command:example>
85898596
</command:examples>
85908597
<command:relatedLinks>
85918598
<maml:navigationLink>
@@ -11802,9 +11809,9 @@ Mode LastWriteTime Length Name
1180211809
</maml:description>
1180311810
</command:details>
1180411811
<maml:description>
11805-
<maml:para>Shows the specified path as a graphical tree in the console. This is intended as PowerShell alternative to the tree DOS command. This function should work for any type of PowerShell provider and can be used to explore providers used for configuration like the WSMan provider or the registry. Currently, this will not work with any PSDrives created with the Certificate provider.</maml:para>
11812+
<maml:para>Shows the specified path as a graphical tree in the console. This is intended as PowerShell alternative to the tree DOS command. This function should work for any type of PowerShell provider and can be used to explore providers used for configuration like the WSMan provider or the registry. Currently, this will not work with any PSDrives created with the Certificate provider. It should work cross-platform.</maml:para>
1180611813
<maml:para>By default, the output will only show directory or equivalent structures. But you can opt to include items well as item details by using the ShowProperty parameter. Specify a comma separated list of properties or use * to view them all.</maml:para>
11807-
<maml:para>It should work cross-platform. If you are running PowerShell 7, there is a dynamic parameter, -InColor, that will write ANSI-colored output to the pipeline. The color scheme is designed for the file system. This parameter has an alias of -ansi.</maml:para>
11814+
<maml:para>If the Path is a FileSystem path there is a dynamic parameter, -InColor, that will write ANSI-colored output to the pipeline. This parameter has an alias of -ansi.</maml:para>
1180811815
<maml:para>Note: This is an update to an older function in my library. I seem to recall I found the original code somewhere online, perhaps from someone like Lee Holmes. Sadly, I neglected to record the source.</maml:para>
1180911816
</maml:description>
1181011817
<command:syntax>
@@ -11869,6 +11876,17 @@ Mode LastWriteTime Length Name
1186911876
</dev:type>
1187011877
<dev:defaultValue>False</dev:defaultValue>
1187111878
</command:parameter>
11879+
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="ansi">
11880+
<maml:name>InColor</maml:name>
11881+
<maml:Description>
11882+
<maml:para>Show tree and item colorized. Values are from the $PSAnsiMap variable.</maml:para>
11883+
</maml:Description>
11884+
<dev:type>
11885+
<maml:name>SwitchParameter</maml:name>
11886+
<maml:uri />
11887+
</dev:type>
11888+
<dev:defaultValue>False</dev:defaultValue>
11889+
</command:parameter>
1187211890
</command:syntaxItem>
1187311891
<command:syntaxItem>
1187411892
<maml:name>Show-Tree</maml:name>
@@ -11931,6 +11949,17 @@ Mode LastWriteTime Length Name
1193111949
</dev:type>
1193211950
<dev:defaultValue>False</dev:defaultValue>
1193311951
</command:parameter>
11952+
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="ansi">
11953+
<maml:name>InColor</maml:name>
11954+
<maml:Description>
11955+
<maml:para>Show tree and item colorized. Values are from the $PSAnsiMap variable.</maml:para>
11956+
</maml:Description>
11957+
<dev:type>
11958+
<maml:name>SwitchParameter</maml:name>
11959+
<maml:uri />
11960+
</dev:type>
11961+
<dev:defaultValue>False</dev:defaultValue>
11962+
</command:parameter>
1193411963
</command:syntaxItem>
1193511964
</command:syntax>
1193611965
<command:parameters>
@@ -12006,6 +12035,18 @@ Mode LastWriteTime Length Name
1200612035
</dev:type>
1200712036
<dev:defaultValue>False</dev:defaultValue>
1200812037
</command:parameter>
12038+
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="ansi">
12039+
<maml:name>InColor</maml:name>
12040+
<maml:Description>
12041+
<maml:para>Show tree and item colorized. Values are from the $PSAnsiMap variable.</maml:para>
12042+
</maml:Description>
12043+
<command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue>
12044+
<dev:type>
12045+
<maml:name>SwitchParameter</maml:name>
12046+
<maml:uri />
12047+
</dev:type>
12048+
<dev:defaultValue>False</dev:defaultValue>
12049+
</command:parameter>
1200912050
</command:parameters>
1201012051
<command:inputTypes>
1201112052
<command:inputType>
@@ -12029,7 +12070,6 @@ Mode LastWriteTime Length Name
1202912070
</command:returnValues>
1203012071
<maml:alertSet>
1203112072
<maml:alert>
12032-
<maml:para>If you are using PowerShell 7, you can use the InColor parameter, or its alias ansi, to display the tree in a color code format.</maml:para>
1203312073
<maml:para>Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/</maml:para>
1203412074
</maml:alert>
1203512075
</maml:alertSet>
@@ -12116,7 +12156,7 @@ WSMan:\
1211612156
</command:example>
1211712157
<command:example>
1211812158
<maml:title>-------------------------- Example 4 --------------------------</maml:title>
12119-
<dev:code>PS C:\&gt; pstree c:\work\alpha -files -properties LastWriteTime,Length
12159+
<dev:code>PS C:\&gt; pstree c:\work\alpha -files -properties LastWriteTime,Length -ansi
1212012160

1212112161
C:\work\Alpha\
1212212162
+-- LastWriteTime = 02/28/2020 11:19:32
@@ -12142,7 +12182,7 @@ C:\work\Alpha\
1214212182
| +--gamma
1214312183
...</dev:code>
1214412184
<dev:remarks>
12145-
<maml:para>Show a tree listing with files including a few user specified properties. This example is using parameter and command aliases.</maml:para>
12185+
<maml:para>Show a tree listing with files including a few user specified properties in color. This example is using parameter and command aliases.</maml:para>
1214612186
</dev:remarks>
1214712187
</command:example>
1214812188
</command:examples>

0 commit comments

Comments
 (0)