Skip to content

Commit e45ae72

Browse files
v2.41.0
1 parent 242b162 commit e45ae72

17 files changed

+759
-218
lines changed

PSScriptTools.psd1

154 Bytes
Binary file not shown.

PSScriptTools.psm1

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ if ($myinvocation.line -match "-verbose") {
55
Write-Verbose "Loading public functions"
66

77
#exclude files that have special requirements
8-
Get-ChildItem -path $PSScriptRoot\functions\*.ps1 -Exclude 'Get-MyCounter.ps1','Get-FileExtensionInfo.ps1' |
9-
ForEach-Object -process {
8+
Get-ChildItem -Path $PSScriptRoot\functions\*.ps1 -Exclude 'Get-MyCounter.ps1', 'Get-FileExtensionInfo.ps1' |
9+
ForEach-Object -Process {
1010
Write-Verbose $_.fullname
1111
. $_.FullName
1212
}
@@ -25,10 +25,10 @@ Write-Verbose "Define the global PSAnsiFileMap variable"
2525
$json = "psansifilemap.json"
2626

2727
#test for user version in $HOME
28-
$userjson = Join-Path -path $HOME -ChildPath $json
29-
$modjson = Join-Path -path $PSScriptRoot -ChildPath $json
28+
$userjson = Join-Path -Path $HOME -ChildPath $json
29+
$modjson = Join-Path -Path $PSScriptRoot -ChildPath $json
3030

31-
if (Test-Path -path $userjson) {
31+
if (Test-Path -Path $userjson) {
3232
$map = $userjson
3333
}
3434
else {
@@ -40,16 +40,16 @@ else {
4040
#need to process the results individually.
4141
$mapData = [System.Collections.Generic.List[object]]::new()
4242

43-
Get-Content -path $map | ConvertFrom-Json | Foreach-Object {$_} | foreach-Object {
43+
Get-Content -Path $map | ConvertFrom-Json | ForEach-Object { $_ } | ForEach-Object {
4444
$entry = [pscustomobject]@{
4545
PSTypeName = "PSAnsiFileEntry"
4646
Description = $_.description
47-
Pattern = $_.pattern
48-
Ansi = $_.ansi
47+
Pattern = $_.pattern
48+
Ansi = $_.ansi
4949
}
5050
$mapData.Add($entry)
5151
}
52-
Set-Variable -Name PSAnsiFileMap -value $mapdata -Scope Global
52+
Set-Variable -Name PSAnsiFileMap -Value $mapdata -Scope Global
5353

5454
Write-Verbose "Define special character map"
5555
$global:PSSpecialChar = @{
@@ -80,7 +80,7 @@ $global:PSSpecialChar = @{
8080
}
8181

8282
Write-Verbose "Defining the variable `$PSSamplePath to the samples folder for this module"
83-
$global:PSSamplePath = Join-Path -path $PSScriptroot -ChildPath Samples
83+
$global:PSSamplePath = Join-Path -Path $PSScriptroot -ChildPath Samples
8484

8585
Write-Verbose "Add ToDo options to the ISE or VS Code"
8686
if ($psEditor) {
@@ -148,15 +148,15 @@ elseif ($psise) {
148148

149149
Function Set-LocationToFile {
150150
[cmdletbinding()]
151-
[alias("sd","jmp")]
151+
[alias("sd", "jmp")]
152152
[OutputType("none")]
153153
Param()
154154

155155
if ($host.name -match "ISE") {
156156

157157
$path = Split-Path -Path $psISE.CurrentFile.FullPath
158-
set-location -path $path
159-
clear-host
158+
Set-Location -Path $path
159+
Clear-Host
160160
}
161161
Else {
162162
Write-Warning "This command must be run the the PowerShell ISE."
@@ -170,11 +170,11 @@ Function Open-PSScriptToolsHelp {
170170
[cmdletbinding()]
171171
Param()
172172
Write-Verbose "Starting $($myinvocation.mycommand)"
173-
$pdf = Join-Path -path $PSScriptRoot -ChildPath PSScriptToolsManual.pdf
173+
$pdf = Join-Path -Path $PSScriptRoot -ChildPath PSScriptToolsManual.pdf
174174
Write-Verbose "Testing the path $pdf"
175175
if (Test-Path -Path $pdf) {
176176
Try {
177-
write-Verbose "Invoking the PDF"
177+
Write-Verbose "Invoking the PDF"
178178
Invoke-Item -Path $pdf -ErrorAction Stop
179179
}
180180
Catch {

PSScriptToolsManual.pdf

10.4 KB
Binary file not shown.

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
## Abstract
66

7-
This module contains a collection of functions, variables, and format files that you can use to enhance your PowerShell scripting work or get more done from a PowerShell prompt with less typing. Most of the commands are designed to work cross-platform. Please post any questions, problems, or feedback at [Issues](https://github.com/jdhitsolutions/PSScriptTools/issues). Any feedback is greatly appreciated.
7+
This module contains a collection of functions, variables, and format files that you can use to enhance your PowerShell scripting work or get more done from a PowerShell prompt with less typing. Most of the commands are designed to work cross-platform. Please post any questions, problems, or feedback at [Issues](https://github.com/jdhitsolutions/PSScriptTools/issues) section of this module's Github repository. Feedback is greatly appreciated.
88

99
The contents of this file and other documentation can be viewed using the `Open-PSScriptToolsHelp` command. You can also use `Get-PSScriptTools` to see a summary of module commands.
1010

@@ -2589,8 +2589,7 @@ If you find this module useful, you might also want to look at my PowerShell too
25892589
+ [Creating and managing custom type extensions](https://github.com/jdhitsolutions/PSTypeExtensionTools)
25902590
+ [Managing scheduled jobs](https://github.com/jdhitsolutions/ScheduledJobTools)
25912591
+ [Running remote commands outside of PowerShell Remoting](https://github.com/jdhitsolutions/PSRemoteOperations).
2592-
+ [Getting memory status and information](https://github.com/jdhitsolutions/MemoryTools)
2593-
+ [Inventorying your PowerShell script library](https://github.com/jdhitsolutions/PSScriptingInventory)
2592+
+ [Automating the PowerShell scripting process](https://github.com/jdhitsolutions/PSFunctionTools)
25942593
+ [A simple command-line task and to-do manager](https://github.com/jdhitsolutions/MyTasks)
25952594

25962595
## Compatibility

changelog.md

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

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

5+
## v2.41.0
6+
7+
+ Added function `Copy-CommandHistory` with an alias of `ch`.
8+
+ Updated `Out-Copy` to ignore ANSI unless specified. [Issue #118](https://github.com/jdhitsolutions/PSScriptTools/issues/118)
9+
+ Added an alias of `oc` for `Out-Copy`.
10+
+ Updated `New-PSFormatXML` to fix ReadOnly property error. [Issue #121](https://github.com/jdhitsolutions/PSScriptTools/issues/121)
11+
+ Updated `Get-ModuleCommand` to include version information and to accept pipeline input.
12+
+ Updated `modulecommand.format.ps1xml` with a new table view called `version`.
13+
+ Updated missing online help links.
14+
+ Updated `README.md`.
15+
516
## v2.40.0
617

718
+ 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).

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:
4+
online version: https://bit.ly/3qfPnwj
55
schema: 2.0.0
66
---
77

docs/Copy-HistoryCommand.md

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
---
2+
external help file: PSScriptTools-help.xml
3+
Module Name: PSScriptTools
4+
online version:
5+
schema: 2.0.0
6+
---
7+
8+
# Copy-HistoryCommand
9+
10+
## SYNOPSIS
11+
12+
Copy a history command line to the clipboard.
13+
14+
## SYNTAX
15+
16+
```yanml
17+
Copy-HistoryCommand [[-ID] <Int32[]>] [-Passthru] [-WhatIf] [-Confirm] [<CommonParameters>]
18+
```
19+
20+
## DESCRIPTION
21+
22+
You can use this command to copy the commandline from a given PowerShell
23+
history item to the clipboard.The default item will the be last history
24+
item. Once copied, you can paste into your following prompt to edit and/or
25+
re-run.
26+
27+
Linux platforms require the xclip utility to be in the path.
28+
29+
Lee Holmes has a similar function called Copy-History in the PowerShell
30+
Cookbook that lets you copy a range of history commands to the clipboard.
31+
32+
## ExampleS
33+
34+
### Example 1
35+
36+
```powershell
37+
PS C:\> Copy-HistoryCommand
38+
```
39+
40+
Copy the last command to the clipboard.
41+
42+
### Example 2
43+
44+
```powershell
45+
PS C:\> Copy-HistoryCommand 25 -passthru
46+
get-process -computername $computer | sort ws -Descending | select -first 3
47+
```
48+
49+
Copy the command from history item 25 to the clipboard and also pass it to the pipeline.
50+
51+
### Example 3
52+
53+
```powershell
54+
PS C:\> Copy-HistoryCommand (100..110)
55+
```
56+
57+
Copy history items 100 through 110 to the clipboard.
58+
59+
### Example 4
60+
61+
```powershell
62+
PS C:\> $c = [scriptblock]::Create($(Copy-HistoryCommand 25 -passthru))
63+
PS C:\> &$c
64+
65+
Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id SI ProcessName
66+
------- ------ ----- ----- ----- ------ -- -- -----------
67+
10414 12744 488164 461596 ...76 3128 0 dns
68+
581 67 171868 141620 ...82 3104 0 MsMpEng
69+
678 48 118132 89572 840 7180 0 ServerManager
70+
```
71+
72+
This copies the command from history item 25 and turns it into a scriptblock.
73+
74+
## PARAMETERS
75+
76+
### -Confirm
77+
78+
Prompts you for confirmation before running the cmdlet.
79+
80+
```yaml
81+
Type: SwitchParameter
82+
Parameter Sets: (All)
83+
Aliases: cf
84+
85+
Required: False
86+
Position: Named
87+
Default value: None
88+
Accept pipeline input: False
89+
Accept wildcard characters: False
90+
```
91+
92+
### -ID
93+
94+
The history ID number. The default is the last command.
95+
96+
```yaml
97+
Type: Int32[]
98+
Parameter Sets: (All)
99+
Aliases:
100+
101+
Required: False
102+
Position: 0
103+
Default value: $(Get-History).Count
104+
Accept pipeline input: False
105+
Accept wildcard characters: False
106+
```
107+
108+
### -Passthru
109+
110+
Use this parameter if you also want to see the command as well as copy it to the clipboard.
111+
112+
```yaml
113+
Type: SwitchParameter
114+
Parameter Sets: (All)
115+
Aliases:
116+
117+
Required: False
118+
Position: Named
119+
Default value: False
120+
Accept pipeline input: False
121+
Accept wildcard characters: False
122+
```
123+
124+
### -WhatIf
125+
126+
Shows what would happen if the cmdlet runs. The cmdlet is not run.
127+
128+
```yaml
129+
Type: SwitchParameter
130+
Parameter Sets: (All)
131+
Aliases: wi
132+
133+
Required: False
134+
Position: Named
135+
Default value: None
136+
Accept pipeline input: False
137+
Accept wildcard characters: False
138+
```
139+
140+
### CommonParameters
141+
142+
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).
143+
144+
## INPUTS
145+
146+
### Int
147+
148+
## OUTPUTS
149+
150+
### None
151+
152+
### System.String
153+
154+
## NOTES
155+
156+
Learn more about PowerShell:
157+
http://jdhitsolutions.com/blog/essential-powershell-resources/
158+
159+
## RELATED LINKS
160+
161+
[Get-History]()
162+
163+
[Set-Clipboard]()
164+
165+
[Out-Copy](Out-Copy.md)

docs/Get-FormatView.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,3 +143,5 @@ Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell
143143
[Get-FormatData]()
144144
145145
[Get-Member]()
146+
147+
[New-PSFormatXML](New-PSFormatXML.md)

docs/Get-ModuleCommand.md

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,20 @@ Get module commands using the default formatted view. You can install this modul
5454
PS C:\> Get-ModuleCommand smbshare -ListAvailable | Format-List
5555
5656
57-
Name : Block-SmbShareAccess
58-
Alias : blsmba
59-
Synopsis : Adds a deny ACE for a trustee to the security descriptor of the SMB share.
60-
61-
Name : Close-SmbOpenFile
62-
Alias : cssmbo
63-
Synopsis : Closes a file that is open by one of the clients of the SMB server.
64-
65-
Name : Close-SmbSession
66-
Alias : cssmbse
67-
Synopsis : Ends forcibly the SMB session.
57+
ModuleName : SmbShare
58+
Name : Block-SmbShareAccess
59+
Alias : blsmba
60+
Synopsis : Adds a deny ACE for a trustee to the security descriptor of the SMB share.
61+
62+
ModuleName : SmbShare
63+
Name : Close-SmbOpenFile
64+
Alias : cssmbo
65+
Synopsis : Closes a file that is open by one of the clients of the SMB server.
66+
67+
ModuleName : SmbShare
68+
Name : Close-SmbSession
69+
Alias : cssmbse
70+
Synopsis : Ends forcibly the SMB session.
6871
...
6972
```
7073

@@ -95,6 +98,24 @@ Compare-Module cmo Function Compare PowerShell module versions.
9598

9699
Display commands using a custom table view called 'Verb'.
97100

101+
### Example 4
102+
103+
```powershell
104+
PS C:\ Get-ModuleCommand PSScriptTools | Format-Table -view version
105+
106+
ModuleName: PSScriptTools [v2.41.0]
107+
108+
Name Alias Compatible PSVersion
109+
---- ----- ---------- ---------
110+
Add-Border ab {Desktop, Core} 5.1
111+
Compare-Module cmo {Desktop, Core} 5.1
112+
Compare-Script csc {Desktop, Core} 5.1
113+
Convert-CommandToHashtable {Desktop, Core} 5.1
114+
...
115+
```
116+
117+
Using the custom table view 'version'.
118+
98119
## PARAMETERS
99120

100121
### -FullyQualifiedName
@@ -151,7 +172,7 @@ Aliases:
151172
Required: True
152173
Position: 0
153174
Default value: None
154-
Accept pipeline input: False
175+
Accept pipeline input: True (ByPropertyName)
155176
Accept wildcard characters: False
156177
```
157178

docs/New-PSFormatXML.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ Accept wildcard characters: False
264264
265265
### -Properties
266266
267-
Enter a set of properties to include. If you don't specify anything then all properties will be used. When creating a Wide view you should only specify a single property. If you specify an invalid property name, the ps1xml file will NOT be created.
267+
Enter a set of properties to include. If you don't specify anything then all properties will be used. When creating a Wide view you should only specify a single property. If you specify an invalid property name, the ps1xml file will NOT be created. Ideally, you will specify an instance of the object that contains a value for all the properties you want to use.
268268
269269
```yaml
270270
Type: Object[]
@@ -379,3 +379,5 @@ Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell
379379
## RELATED LINKS
380380
381381
[Update-FormatData]()
382+
383+
[Get-FormatView](Get-FormatView.md)

0 commit comments

Comments
 (0)