Skip to content

Commit

Permalink
revised help
Browse files Browse the repository at this point in the history
  • Loading branch information
jdhitsolutions committed Dec 14, 2017
1 parent 60fe978 commit 751f7c5
Show file tree
Hide file tree
Showing 19 changed files with 1,183 additions and 270 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ You can use the menu or keyboard shortcut which will launch an input box.

The comment will be inserted at the current cursor location.
In VS Code, access the command palette (Ctrl+Shift+P) and then "PowerShell: Show Additional Commands from PowerShell Modules". Select "Insert ToDo" from the list and you'll get the same input box. Note that this will only work for PowerShell files.

### Compatibility
Where possible these commands have been tested with PowerShell Core, but not every platform. If you encounter problems,have suggestions or other feedback, please post an issue.

Expand Down
104 changes: 0 additions & 104 deletions Utilities.ps1
Original file line number Diff line number Diff line change
@@ -1,71 +1,7 @@


Function Get-PowerShellEngine {
<#
.Synopsis
Get the path to the current PowerShell engine
.Description
Use this command to find the path to the PowerShell executable, or engine that is running your current session. The path for PowerShell 6 is different than previous versions.

The default is to provide the path only. But you can also get detailed information
.Parameter Detail
Include additional information. Not all properties may have values depending on operating system and PowerShell version.
.Example
PS C:\> Get-PowerShellEngine
C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe
.Example
PS C:\> Get-PowerShellEngine -detail
Path : C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe
FileVersion : 10.0.15063.0 (WinBuild.160101.0800)
PSVersion : 5.1.15063.502
ProductVersion : 10.0.15063.0
Edition : Desktop
Host : Visual Studio Code Host
Culture : en-US
Platform :
Result from running in the Visual Studio Code integrated PowerShell terminal
.Example
PS C:\> Get-PowerShellEngine -detail
Path : C:\Program Files\PowerShell\6.0.0-beta.5\powershell.exe
FileVersion :
PSVersion : 6.0.0-beta
ProductVersion :
Edition : Core
Host : ConsoleHost
Culture : en-US
Platform : Win32NT
Result from running in a PowerShell 6 session on Windows 10
.Example
PS /home/> get-powershellengine -Detail
Path : /opt/microsoft/powershell/6.0.0-beta.5/powershell
FileVersion :
PSVersion : 6.0.0-beta
ProductVersion :
Edition : Core
Host : ConsoleHost
Culture : en-US
Platform : Unix
Result from running in a PowerShell session on Linux
.Link
$PSVersionTable
.Link
$Host
.Link
Get-Process
.Outputs
[string]
[pscustomobject]
#>
[CmdletBinding()]
Param([switch]$Detail)

Expand All @@ -89,46 +25,6 @@ Function Get-PowerShellEngine {
}

Function Out-More {
<#
.Synopsis
Send "pages" of objects to the pipeline.
.Description
This function is designed to display groups or "pages" of objects to the PowerShell pipeline. It is modeled after the legacy More.com command line utility.
By default the command will write out objects out to the pipeline in groups of 50. You will be prompted after each grouping. Pressing M or Enter will get the next group. Pressing A will stop paging and display all of the remaining objects. Pressing N will display the next object. Press Q to stop writing anything else to the pipeline.
.Parameter ClearScreen
Clear the screen prior to writing data to the pipeline. This parameter has an alias of cls.
.Parameter Count
The number of objects to group together in a page. This parameter has an alias of i.
.Example
PS C:\> get-process | out-more -count 10
Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id SI ProcessName
------- ------ ----- ----- ----- ------ -- -- -----------
1031 75 122588 81092 841 31.30 1872 1 BoxSync
57 3 488 968 12 0.02 1068 1 BoxSyncMonitor
103 9 1448 4220 67 0.02 1632 0 BtwRSupportService
80 9 3008 8588 ...27 21.00 5192 1 conhost
40 5 752 2780 ...82 0.00 5248 0 conhost
53 7 972 3808 ...07 0.02 6876 1 conhost
482 17 1932 3692 56 0.91 708 0 csrss
520 30 2488 134628 180 31.67 784 1 csrss
408 18 6496 12436 ...35 0.56 1684 0 dasHost
180 14 3348 6748 66 0.50 4688 0 devmonsrv
[M]ore [A]ll [N]ext [Q]uit
Display processes in groups of 10.
.Example
PS C:\> dir c:\work -file -Recurse | out-more -ClearScreen | tee -Variable work
List all files in C:\Work and page them to Out-More using the default count, but after clearing the screen first.
The results are then piped to Tee-Object which saves them to a variable.
.Notes
Learn more about PowerShell:
http://jdhitsolutions.com/blog/essential-powershell-resources/
.Link
http://jdhitsolutions.com/blog/powershell/4707/a-better-powershell-more/
.Inputs
System.Object[]
.Outputs
System.Object
#>

[cmdletbinding()]
Param(
Expand Down
85 changes: 48 additions & 37 deletions docs/Add-Border.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ Create a text border around a string.

### single (Default)
```
Add-Border [-Text] <String> [-Character <String>] [-InsertBlanks] [-Tab <Int32>]
Add-Border [-Text] <String> [-Character <String>] [-InsertBlanks] [-Tab <Int32>] [<CommonParameters>]
```

### block
```
Add-Border [-TextBlock] <String[]> [-Character <String>] [-InsertBlanks] [-Tab <Int32>]
Add-Border [-TextBlock] <String[]> [-Character <String>] [-InsertBlanks] [-Tab <Int32>] [<CommonParameters>]
```

## DESCRIPTION
Expand All @@ -28,25 +28,27 @@ You might use this to create a formatted text report or to improve the display o

## EXAMPLES

### Example 1
### EXAMPLE 1
```
PS C:\> add-border "PowerShell Wins!"
********************
* PowerShell Wins! *
********************
```
### Example 2

### EXAMPLE 2
```
PS C:\> add-border "PowerShell Wins!" -tab 1
********************
* PowerShell Wins! *
********************
```
Note that this example may not format properly in the console.

### Example 3
Note that this EXAMPLE may not format properly in the console.

### EXAMPLE 3
```
PS C:\> add-border "PowerShell Wins!" -character "-" -insertBlanks
Expand All @@ -57,7 +59,7 @@ PS C:\> add-border "PowerShell Wins!" -character "-" -insertBlanks
--------------------
```

### Example 4
### EXAMPLE 4
```
PS C:\> add-border -textblock (get-service win* | out-string).trim()
Expand All @@ -70,10 +72,42 @@ PS C:\> add-border -textblock (get-service win* | out-string).trim()
* Stopped WinRM Windows Remote Management (WS-Manag... *
**********************************************************************
```

Create a border around the output of a Get-Service command.

## PARAMETERS

### -Text
A single line of text that will be wrapped in a border.

```yaml
Type: String
Parameter Sets: single
Aliases:

Required: True
Position: 1
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False
```
### -TextBlock
A multiline block of text.
You might want to trim blank lines from the beginning, end or both.
```yaml
Type: String[]
Parameter Sets: block
Aliases:

Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Character
The character to use for the border. It must be a single character.
Expand Down Expand Up @@ -119,42 +153,19 @@ Accept pipeline input: False
Accept wildcard characters: False
```
### -Text
A single line of text that will be wrapped in a border.
```yaml
Type: String
Parameter Sets: single
Aliases:

Required: True
Position: 1
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False
```
### -TextBlock
A multiline block of text.
You might want to trim blank lines from the beginning, end or both.
```yaml
Type: String[]
Parameter Sets: block
Aliases:

Required: True
Position: 1
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
### None
## OUTPUTS
### System.String
## NOTES
Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/
## RELATED LINKS
10 changes: 7 additions & 3 deletions docs/Copy-Command.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Copy a PowerShell command.

```
Copy-Command [-Command] <String> [[-NewName] <String>] [-IncludeDynamic] [-AsProxy] [-UseForwardHelp]
[<CommonParameters>]
```

## DESCRIPTION
Expand All @@ -23,21 +24,21 @@ For best results, run this in the PowerShell ISE of Visual Studio code, the copi

## EXAMPLES

### Example 1
### EXAMPLE 1
```
PS C:\> Copy-Command Get-Process Get-MyProcess
```

Create a copy of Get-Process called Get-MyProcess.

### Example 2
### EXAMPLE 2
```
PS C:\> Copy-Command Get-Eventlog -asproxy -useforwardhelp
```

Create a proxy function for Get-Eventlog and use forwarded help links.

### Example 3
### EXAMPLE 3
```
PS C:\> Copy-Command Get-ADComputer Get-MyADComputer -includedynamic
```
Expand Down Expand Up @@ -121,6 +122,9 @@ 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
### None
Expand Down
15 changes: 10 additions & 5 deletions docs/Format-Percent.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,29 @@ Format a value as a percentage.

### None (Default)
```
Format-Percent [-Value] <Object> [-Total] <Object> [-Decimal <Int32>]
Format-Percent [-Value] <Object> [-Total] <Object> [-Decimal <Int32>] [<CommonParameters>]
```

### String
```
Format-Percent [-Value] <Object> [-Total] <Object> [-Decimal <Int32>] [-AsString]
Format-Percent [-Value] <Object> [-Total] <Object> [-Decimal <Int32>] [-AsString] [<CommonParameters>]
```

## DESCRIPTION
This command calculates a percentage of a value from a total, with the formula (value/total)*100. The default is to return a value to 2 decimal places but you can configure that with -Decimal. There is also an option to format the percentage as a string which will include the % symbol.

## EXAMPLES

### Example 1
### EXAMPLE 1
```
PS C:\> Format-Percent -value 1234.567 -total 5000 -decimal 4
24.6913
```

Calculate a percentage from 1234.567 out of 5000 (i.e. 1234.567/5000) to 4 decimal points.

### Example 2
### EXAMPLE 2
```
PS C:\> get-ciminstance win32_operatingsystem -computer chi-dc04 | select PSComputername,TotalVisibleMemorySize,@{Name="PctFreeMem";Expression={ Format-Percent $_.FreePhysicalMemory $_.TotalVisibleMemorySize}}
Expand All @@ -44,14 +45,15 @@ PSComputerName TotalVisibleMemorySize PctFreeMem
chi-dc04 1738292 23.92
```

### Example 3
### EXAMPLE 3
```
PS C:\> get-ciminstance win32_operatingsystem -computer chi-dc04 | select PSComputername,TotalVisibleMemorySize,@{Name="PctFreeMem";Expression={ Format-Percent $_.FreePhysicalMemory $_.TotalVisibleMemorySize -asString}}
PSComputerName TotalVisibleMemorySize PctFreeMem
-------------- ---------------------- ----------
chi-dc04 1738292 23.92%
```

## PARAMETERS

### -Value
Expand Down Expand Up @@ -114,6 +116,9 @@ 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
### System.Object
Expand Down
Loading

0 comments on commit 751f7c5

Please sign in to comment.