Skip to content

Commit 03b248e

Browse files
3.1.0 updates
1 parent 12b52c9 commit 03b248e

91 files changed

Lines changed: 1094 additions & 941 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

PSScriptTools.psd1

-12 Bytes
Binary file not shown.

README.md

Lines changed: 44 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -130,59 +130,33 @@ If the function relies on external or additional files, you will have to copy th
130130

131131
### [Get-PSProfile](docs/Get-PSProfile.md)
132132

133-
This command is designed for Windows systems and makes it easy to identify all possible PowerShell profile scripts. Including those for hosts such as VSCode or the PowerShell ISE. The command writes a custom object to the pipeline which has defined formatting. The default view is a table.
133+
This command is designed to make it easy to identify all possible PowerShell profile scripts. Including those for hosts such as VSCode or the PowerShell ISE. The command writes a custom object to the pipeline which has defined formatting. The default view is a table.
134134

135-
```dos
136-
PS C:\> Get-PSProfile
137-
138-
Name: PowerShell
135+
![Get-PSProfile Windows](images/get-psprofile-windows.png)
139136

140-
Scope Path Exists
141-
----- ---- ------
142-
AllUsersCurrentHost C:\Program Files\PowerShell\7\Microsoft.PowerShell_profile.ps1 False
143-
AllUsersAllHosts C:\Program Files\PowerShell\7\profile.ps1 False
144-
CurrentUserAllHosts C:\Users\Jeff\Documents\PowerShell\profile.ps1 True
145-
CurrentUserCurrentHost C:\Users\Jeff\Documents\PowerShell\Microsoft.PowerShell_profile.ps1 True
146-
147-
148-
Name: Windows PowerShell
149-
150-
Scope Path Exists
151-
----- ---- ------
152-
AllUsersCurrentHost C:\WINDOWS\System32\WindowsPowerShell\v1.0\Microsoft.PowerShell... True
153-
AllUsersAllHosts C:\WINDOWS\System32\WindowsPowerShell\v1.0\profile.ps1 True
154-
CurrentUserAllHosts C:\Users\Jeff\Documents\WindowsPowerShell\profile.ps1 True
155-
CurrentUserCurrentHost C:\Users\Jeff\Documents\WindowsPowerShell\Microsoft.PowerShell_p... True
156-
```
137+
![Get-PSProfile Linux](images/get-psprofile-linux.png)
157138

158139
There is also a list view.
159140

160141
```dos
161-
PS C:\> Get-PSProfile | Where-Object {$_.name -eq 'powershell'} | Format-List
162-
142+
PS C:\> Get-PSProfile | Where-Object {$_.name -eq 'powershell' -AND $_.Exists} | Format-List
163143
164144
Name: PowerShell
165145
166-
167-
Scope : AllUsersCurrentHost
168-
Path : C:\Program Files\PowerShell\7\Microsoft.PowerShell_profile.ps1
169-
Exists : False
170-
LastModified :
171-
172146
Scope : AllUsersAllHosts
173147
Path : C:\Program Files\PowerShell\7\profile.ps1
174-
Exists : False
175-
LastModified :
148+
Exists : True
149+
LastModified : 2/23/2022 1:27:30 PM
176150
177151
Scope : CurrentUserAllHosts
178152
Path : C:\Users\Jeff\Documents\PowerShell\profile.ps1
179153
Exists : True
180-
LastModified : 9/9/2024 2:35:45 PM
154+
LastModified : 10/5/2020 3:50:19 PM
181155
182156
Scope : CurrentUserCurrentHost
183157
Path : C:\Users\Jeff\Documents\PowerShell\Microsoft.PowerShell_profile.ps1
184158
Exists : True
185-
LastModified : 9/9/2024 2:03:44 PM
159+
LastModified : 10/5/2020 3:50:19 PM
186160
```
187161

188162
### [Get-MyAlias](docs/Get-MyAlias.md)
@@ -212,67 +186,66 @@ This is an alternative to `Get-Command` to make it easier to see at a glance wha
212186
```dos
213187
PS C:\> Get-ModuleCommand PSCalendar -ListAvailable
214188
215-
ModuleName: PSCalendar [v2.9.0]
216-
217-
Name Alias Synopsis
218-
---- ----- --------
219-
Get-Calendar cal Displays a visual representation of a
220-
calendar.
221-
Get-MonthName Get the list of month names.
222-
Get-NCalendar ncal Display a Linux-style ncal calendar.
223-
Get-PSCalendarConfiguration Get the current PSCalendar ANSI configuration.
224-
Set-PSCalendarConfiguration Modify the PSCalendar ANSI configuration.
225-
Show-Calendar scal Display a colorized calendar month in the
226-
console.
227-
Show-GuiCalendar gcal Display a WPF-based calendar.
228-
Show-PSCalendarHelp Display a help PDF file for the PSCalendar
229-
module.
189+
ModuleName: PSCalendar [v2.10.1]
190+
191+
Name Alias Synopsis
192+
---- ----- --------
193+
Export-PSCalendarConfiguration Save-PSCalendarConfiguration Save the current calendar configuration
194+
settings to a file.
195+
Get-Calendar cal Displays a visual representation of a
196+
calendar.
197+
Get-MonthName mon Get the list of month names.
198+
Get-NCalendar ncal Display a Linux-style ncal calendar.
199+
Get-PSCalendarConfiguration Get the current PSCalendar ANSI
200+
configuration.
201+
Set-PSCalendarConfiguration Modify the PSCalendar ANSI
202+
configuration.
203+
Show-Calendar scal Display a colorized calendar month in
204+
the console.
205+
Show-GuiCalendar gcal Display a WPF-based calendar.
206+
Show-PSCalendarHelp Display a help PDF file for the PSCalendar module.
230207
```
231208

232209
There are also alternate table views.
233210

234211
```dos
235212
PS C:\> Get-ModuleCommand PSCalendar | Format-Table -View verb
236213
214+
Verb: Export
215+
216+
Name Alias Type Synopsis
217+
---- ----- ---- --------
218+
Export-PSCalendarConfiguration Save-PSCalendar Function Save the current calendar configuration
219+
Configuration settings to a file.
220+
237221
Verb: Get
238222
239223
Name Alias Type Synopsis
240224
---- ----- ---- --------
241-
Get-Calendar cal Function Displays a visual
242-
representation of a
225+
Get-Calendar cal Function Displays a visual representation of a
243226
calendar.
244-
Get-MonthName Function Get the list of
245-
month names.
246-
Get-NCalendar ncal Function Display a
247-
Linux-style ncal
248-
calendar.
249-
Get-PSCalendarConfiguration Function Get the current
250-
PSCalendar ANSI
227+
Get-MonthName mon Function Get the list of month names.
228+
Get-NCalendar ncal Function Display a Linux-style ncal calendar.
229+
Get-PSCalendarConfiguration Function Get the current PSCalendar ANSI
251230
configuration.
252231
253-
254232
Verb: Set
255233
256234
Name Alias Type Synopsis
257235
---- ----- ---- --------
258-
Set-PSCalendarConfiguration Function Modify the
259-
PSCalendar ANSI
236+
Set-PSCalendarConfiguration Function Modify the PSCalendar ANSI
260237
configuration.
261238
262-
263239
Verb: Show
264240
265241
Name Alias Type Synopsis
266242
---- ----- ---- --------
267-
Show-Calendar scal Function Display a colorized
268-
calendar month in
243+
Show-Calendar scal Function Display a colorized calendar month in
269244
the console.
270-
Show-GuiCalendar gcal Function Display a WPF-based
271-
calendar.
272-
Show-PSCalendarHelp Function Display a help PDF
273-
file for the
245+
Show-GuiCalendar gcal Function Display a WPF-based calendar.
246+
Show-PSCalendarHelp Function Display a help PDF file for the
274247
PSCalendar module.
275-
```
248+
```
276249
277250
Get module commands using the default formatted view. There is also a default view for `Format-List`.
278251
@@ -608,9 +581,9 @@ You can also get detailed information.
608581

609582
![Windows PowerShell](images/get-powershellengine1.png)
610583

611-
![PowerShell Core on Windows](images/get-powershellengine2.png)
584+
![PowerShell 7 on Windows](images/get-powershellengine2.png)
612585

613-
![PowerShell Core on Linux](images/get-powershellengine3.png)
586+
![PowerShell 7 on Linux](images/get-powershellengine3.png)
614587

615588
Results will vary depending on whether you are running PowerShell on Windows or non-Windows systems.
616589

archive/ConvertTo-ASCIIArt.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: https://bit.ly/32DadcG
4+
online version:
55
schema: 2.0.0
66
---
77

archive/ConvertTo-ASCIIArt.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ Function ConvertTo-ASCIIArt {
4242
}
4343

4444
Register-ArgumentCompleter -CommandName ConvertTo-ASCIIArt -ParameterName Font -ScriptBlock {
45-
param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter)
45+
param($commandName, $parameterName, $WordToComplete, $commandAst, $fakeBoundParameter)
4646

4747
(Invoke-RestMethod https://artii.herokuapp.com/fonts_list).split() |
48-
Where-Object { $_ -like "$wordToComplete*" } |
48+
Where-Object { $_ -like "$WordToComplete*" } |
4949
ForEach-Object {
5050
[System.Management.Automation.CompletionResult]::new($_.Trim(), $_.Trim(), 'ParameterValue', $_)
5151
}

changelog.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,34 @@
33
This file contains the most recent change history for the PSScriptTools module.
44

55
## [Unreleased]
6+
### Added
7+
- Added the parameter `NoComments` to `New-PSFormatXml` to suppress the default helper comments.
8+
- Added a parameter alias `Property` for `Properties` in `New-PSFormatXML`.
9+
- Added a parameter alias `Property` for `Properties` in `New-PSFormatXML`.
10+
- Added alias `isAdmin` to `Test-IsElevated`.
11+
12+
### Changed
13+
- Updated `Convert-CommandToHashTable` to better handle a hashtable as a paremeter value.
14+
- Updated `ConvertTo-Hashtable` to using PSObject` to get property names.
15+
- Updated `ConvertTo-Hashtable` to make an alphabetically sorted hashtable an ordered hashtable.
16+
- Updated `Convert-HashtableToCode` to accept a standard or ordered hashtable as input.
17+
- Revised `Get-MyVariable`. Removed the `-NoTypeInformation` and made it opt-in with -IncludeTypeInformation`. __This is a breaking change.__
18+
- Revised `Get-MyVariable` to get initial variables from a new PowerShell instance.
19+
- Revised `Get-MyAlias` to let user specify a name. The new version also skips aliases from common modules like PSReadline and Microsoft.PowerShell.PSResourceGet.
20+
- Revised formatting for `Get-ModuleCommand` to add a link to online help for each command if running PowerShell 7.
21+
- Updated `New-PSFormatXML` to incorporate a suggestion from [@scriptingstudio](https://github.com/scriptingstudio). [[Issue #155](https://github.com/jdhitsolutions/PSScriptTools/issues/155)]
22+
- Updated `Get-PSProfile` to support non-Windows platforms. Reformatted the default table view.
23+
- Updated `README`.
24+
- Updated `Get-PSLocation` to include locations in `%PSModulePath%` Also corrected values for `HOME` and `Documents`. These changes also meant updating the custom formatting file..
25+
- Updated `Get-PowerShellEngine` to define a type name (`PSEngine`) when writing a detailed object.
26+
- Modified `Show-ANSISequence` to adjust number of columns to display in PowerShell 7.
27+
- Code cleanup.
28+
- Help updates.
29+
- Replaced bit.ly online help links.
30+
31+
### Fixed
32+
- Fixed bug in `Get-ModuleCommand` that failed to retrieve all command aliases.
33+
- Fixed error in DirectoryStat sizeKB format view that wasn't showing values in KB
634

735
## [3.0.0] - 2025-03-26
836

docs/Convert-CommandToHashtable.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,36 @@ Convert-CommandToHashtable [-Text] <String> [<CommonParameters>]
1919

2020
## DESCRIPTION
2121

22-
This command is intended to convert a long PowerShell expression with named parameters into a splatting alternative. The central concept is that you are editing a script file with a lengthy PowerShell expression with multiple parameters and you would like to turn it into splatting code.
22+
This command is intended to convert a long PowerShell expression with named parameters into a splatting alternative. The central concept is that you are editing a script file with a lengthy PowerShell expression with multiple parameters and you would like to turn it into splatting code. For best results, the command expression should use parameter names and not rely on positional parameters.
23+
24+
The command may produce an invalid hashtable with complex expressions as parameter values.
2325

2426
## EXAMPLES
2527

2628
### Example 1
2729

2830
```powershell
29-
PS C:\> $text ="Get-WinEvent -ListLog p* -computername SRV1 -ErrorAction stop"
31+
PS C:\> $text = "Get-WinEvent -ListLog p* -computername SRV1 -ErrorAction stop"
3032
PS C:\> Convert-CommandToHashtable -Text $text | Set-Clipboard
3133
```
3234

3335
The $text variable might be a line of code from your script. The second line converts into a splatting sequence and copies it to the Windows clipboard so you can paste it back into your script. You could create a VS Code task sequence using this function.
3436

37+
### Example 2
38+
39+
```powershell
40+
PS C:\> Convert-CommandToHashtable -Text (h 149).Commandline
41+
$paramHash = @{
42+
path = "c:\work"
43+
filter = "*.ps1"
44+
recurse = $True
45+
}
46+
47+
Get-ChildItem @paramHash
48+
```
49+
50+
Convert command 149 from command history into a hashtable.
51+
3552
## PARAMETERS
3653

3754
### -Text

docs/Convert-HashtableToCode.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,25 @@ Convert a hashtable to a string representation.
1616
### psd1 (Default)
1717

1818
```yaml
19-
Convert-HashtableToCode [-Hashtable] <Hashtable> [-Indent <Int32>]
20-
[<CommonParameters>]
19+
Convert-HashtableToCode [-Hashtable] <Object> [-Indent <Int32>] [<CommonParameters>]
2120
```
2221

2322
### inline
2423

2524
```yaml
26-
Convert-HashtableToCode [-Hashtable] <Hashtable> [-Inline] [<CommonParameters>]
25+
Convert-HashtableToCode [-Hashtable] <Object> [-Inline] [<CommonParameters>]
2726
```
2827

2928
## DESCRIPTION
3029

31-
Use this command to convert a hashtable into its text or string equivalent. It is assumed that any array values contain items of the same type. This command has not been tested with large or complex hashtables, so you might need to manually edit the output to meet your tastes or requirements.
30+
Use this command to convert a hashtable into its text or string equivalent. It is assumed that any array values contain items of the same type. This command has not been tested with large or complex hash tables, so you might need to manually edit the output to meet your requirements.
3231

3332
## EXAMPLES
3433

3534
### Example 1
3635

3736
```powershell
38-
PS C:\> $h = @{Name="SRV1";Asset=123454;Location="Omaha"}
37+
PS C:\> $h = [ordered]@{Name="SRV1";Asset=123454;Location="Omaha"}
3938
PS C:\> Convert-HashtableToCode $h
4039
@{
4140
Name = 'SRV1'
@@ -44,7 +43,7 @@ PS C:\> Convert-HashtableToCode $h
4443
}
4544
```
4645

47-
Convert a hashtable object to a string equivalent that you can copy into your script.
46+
Convert an ordered hashtable object to a string equivalent that you can copy into your script.
4847

4948
### Example 2
5049

@@ -63,7 +62,7 @@ Create an inline string version of the hashtable.
6362
A hashtable to convert. It can be standard or ordered hashtable.
6463

6564
```yaml
66-
Type: Hashtable
65+
Type: Object
6766
Parameter Sets: (All)
6867
Aliases:
6968

@@ -76,7 +75,7 @@ Accept wildcard characters: False
7675
7776
### -Indent
7877
79-
Specify the number of tabs to indent. You shouldn't need to specify this parameter. It exists for situations where there are nested hashtables.
78+
Specify the number of tabs to indent. You shouldn't need to specify this parameter. It exists for situations where there are nested hash tables.
8079
8180
```yaml
8281
Type: Int32

docs/Convert-HtmlToAnsi.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: https://bit.ly/3qfPnwj
4+
online version: https://jdhitsolutions.com/yourls/e41450
55
schema: 2.0.0
66
---
77

docs/ConvertTo-Hashtable.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@ This command will take an object and create a hashtable based on its properties.
2727
### Example 1
2828

2929
```powershell
30-
PS C:\> Get-Process -id $pid |
31-
Select-Object name,id,handles,WorkingSet |
32-
ConvertTo-Hashtable
30+
PS C:\> Get-Process -id $pid | Select-Object name,id,handles,WorkingSet | ConvertTo-Hashtable
3331
3432
Name Value
3533
---- -----

docs/ConvertTo-TitleCase.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: https://bit.ly/3gQclWl
4+
online version: https://jdhitsolutions.com/yourls/7011bb
55
schema: 2.0.0
66
---
77

0 commit comments

Comments
 (0)