Skip to content

Commit

Permalink
v2.41.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jdhitsolutions committed Jan 18, 2022
1 parent 39ff8d2 commit 13ddcb4
Show file tree
Hide file tree
Showing 16 changed files with 759 additions and 218 deletions.
Binary file modified PSScriptTools.psd1
Binary file not shown.
30 changes: 15 additions & 15 deletions PSScriptTools.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ if ($myinvocation.line -match "-verbose") {
Write-Verbose "Loading public functions"

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

#test for user version in $HOME
$userjson = Join-Path -path $HOME -ChildPath $json
$modjson = Join-Path -path $PSScriptRoot -ChildPath $json
$userjson = Join-Path -Path $HOME -ChildPath $json
$modjson = Join-Path -Path $PSScriptRoot -ChildPath $json

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

Get-Content -path $map | ConvertFrom-Json | Foreach-Object {$_} | foreach-Object {
Get-Content -Path $map | ConvertFrom-Json | ForEach-Object { $_ } | ForEach-Object {
$entry = [pscustomobject]@{
PSTypeName = "PSAnsiFileEntry"
Description = $_.description
Pattern = $_.pattern
Ansi = $_.ansi
Pattern = $_.pattern
Ansi = $_.ansi
}
$mapData.Add($entry)
}
Set-Variable -Name PSAnsiFileMap -value $mapdata -Scope Global
Set-Variable -Name PSAnsiFileMap -Value $mapdata -Scope Global

Write-Verbose "Define special character map"
$global:PSSpecialChar = @{
Expand Down Expand Up @@ -80,7 +80,7 @@ $global:PSSpecialChar = @{
}

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

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

Function Set-LocationToFile {
[cmdletbinding()]
[alias("sd","jmp")]
[alias("sd", "jmp")]
[OutputType("none")]
Param()

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

$path = Split-Path -Path $psISE.CurrentFile.FullPath
set-location -path $path
clear-host
Set-Location -Path $path
Clear-Host
}
Else {
Write-Warning "This command must be run the the PowerShell ISE."
Expand All @@ -170,11 +170,11 @@ Function Open-PSScriptToolsHelp {
[cmdletbinding()]
Param()
Write-Verbose "Starting $($myinvocation.mycommand)"
$pdf = Join-Path -path $PSScriptRoot -ChildPath PSScriptToolsManual.pdf
$pdf = Join-Path -Path $PSScriptRoot -ChildPath PSScriptToolsManual.pdf
Write-Verbose "Testing the path $pdf"
if (Test-Path -Path $pdf) {
Try {
write-Verbose "Invoking the PDF"
Write-Verbose "Invoking the PDF"
Invoke-Item -Path $pdf -ErrorAction Stop
}
Catch {
Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## Abstract

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.
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.

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.

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

## Compatibility
Expand Down
11 changes: 11 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@

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

## v2.41.0

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

## v2.40.0

+ 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).
Expand Down
2 changes: 1 addition & 1 deletion docs/Convert-HtmlToAnsi.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/3qfPnwj
schema: 2.0.0
---

Expand Down
165 changes: 165 additions & 0 deletions docs/Copy-HistoryCommand.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
---
external help file: PSScriptTools-help.xml
Module Name: PSScriptTools
online version:
schema: 2.0.0
---

# Copy-HistoryCommand

## SYNOPSIS

Copy a history command line to the clipboard.

## SYNTAX

```yanml
Copy-HistoryCommand [[-ID] <Int32[]>] [-Passthru] [-WhatIf] [-Confirm] [<CommonParameters>]
```

## DESCRIPTION

You can use this command to copy the commandline from a given PowerShell
history item to the clipboard.The default item will the be last history
item. Once copied, you can paste into your following prompt to edit and/or
re-run.

Linux platforms require the xclip utility to be in the path.

Lee Holmes has a similar function called Copy-History in the PowerShell
Cookbook that lets you copy a range of history commands to the clipboard.

## ExampleS

### Example 1

```powershell
PS C:\> Copy-HistoryCommand
```

Copy the last command to the clipboard.

### Example 2

```powershell
PS C:\> Copy-HistoryCommand 25 -passthru
get-process -computername $computer | sort ws -Descending | select -first 3
```

Copy the command from history item 25 to the clipboard and also pass it to the pipeline.

### Example 3

```powershell
PS C:\> Copy-HistoryCommand (100..110)
```

Copy history items 100 through 110 to the clipboard.

### Example 4

```powershell
PS C:\> $c = [scriptblock]::Create($(Copy-HistoryCommand 25 -passthru))
PS C:\> &$c
Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id SI ProcessName
------- ------ ----- ----- ----- ------ -- -- -----------
10414 12744 488164 461596 ...76 3128 0 dns
581 67 171868 141620 ...82 3104 0 MsMpEng
678 48 118132 89572 840 7180 0 ServerManager
```

This copies the command from history item 25 and turns it into a scriptblock.

## PARAMETERS

### -Confirm

Prompts you for confirmation before running the cmdlet.

```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases: cf

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -ID
The history ID number. The default is the last command.
```yaml
Type: Int32[]
Parameter Sets: (All)
Aliases:

Required: False
Position: 0
Default value: $(Get-History).Count
Accept pipeline input: False
Accept wildcard characters: False
```
### -Passthru
Use this parameter if you also want to see the command as well as copy it to the clipboard.
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
```
### -WhatIf
Shows what would happen if the cmdlet runs. The cmdlet is not run.
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases: wi

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
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).
## INPUTS
### Int
## OUTPUTS
### None
### System.String
## NOTES
Learn more about PowerShell:
http://jdhitsolutions.com/blog/essential-powershell-resources/
## RELATED LINKS
[Get-History]()
[Set-Clipboard]()
[Out-Copy](Out-Copy.md)
2 changes: 2 additions & 0 deletions docs/Get-FormatView.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,5 @@ Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell
[Get-FormatData]()
[Get-Member]()
[New-PSFormatXML](New-PSFormatXML.md)
45 changes: 33 additions & 12 deletions docs/Get-ModuleCommand.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,20 @@ Get module commands using the default formatted view. You can install this modul
PS C:\> Get-ModuleCommand smbshare -ListAvailable | Format-List
Name : Block-SmbShareAccess
Alias : blsmba
Synopsis : Adds a deny ACE for a trustee to the security descriptor of the SMB share.
Name : Close-SmbOpenFile
Alias : cssmbo
Synopsis : Closes a file that is open by one of the clients of the SMB server.
Name : Close-SmbSession
Alias : cssmbse
Synopsis : Ends forcibly the SMB session.
ModuleName : SmbShare
Name : Block-SmbShareAccess
Alias : blsmba
Synopsis : Adds a deny ACE for a trustee to the security descriptor of the SMB share.
ModuleName : SmbShare
Name : Close-SmbOpenFile
Alias : cssmbo
Synopsis : Closes a file that is open by one of the clients of the SMB server.
ModuleName : SmbShare
Name : Close-SmbSession
Alias : cssmbse
Synopsis : Ends forcibly the SMB session.
...
```

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

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

### Example 4

```powershell
PS C:\ Get-ModuleCommand PSScriptTools | Format-Table -view version
ModuleName: PSScriptTools [v2.41.0]
Name Alias Compatible PSVersion
---- ----- ---------- ---------
Add-Border ab {Desktop, Core} 5.1
Compare-Module cmo {Desktop, Core} 5.1
Compare-Script csc {Desktop, Core} 5.1
Convert-CommandToHashtable {Desktop, Core} 5.1
...
```

Using the custom table view 'version'.

## PARAMETERS

### -FullyQualifiedName
Expand Down Expand Up @@ -151,7 +172,7 @@ Aliases:
Required: True
Position: 0
Default value: None
Accept pipeline input: False
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```
Expand Down
4 changes: 3 additions & 1 deletion docs/New-PSFormatXML.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ Accept wildcard characters: False
### -Properties
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.
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.
```yaml
Type: Object[]
Expand Down Expand Up @@ -379,3 +379,5 @@ Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell
## RELATED LINKS
[Update-FormatData]()
[Get-FormatView](Get-FormatView.md)
Loading

0 comments on commit 13ddcb4

Please sign in to comment.