Skip to content

Commit

Permalink
v1.1.0
Browse files Browse the repository at this point in the history
Cleaned up ToDo code (Issue #12)
Updated README
Help cleanup
  • Loading branch information
jdhitsolutions committed Sep 15, 2018
1 parent 447c045 commit 30303ba
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 29 deletions.
10 changes: 10 additions & 0 deletions .github/ISSUE_TEMPLATE.md
@@ -0,0 +1,10 @@
### PSVersion Table
<!-- copy the contents of $PSVersionTable -->

### What is the syntax or expression you are using?
<!-- copy command you are trying to run -->

### What happens?
<!-- copy the results especially any error messages -->

### What do you think should happen?
Binary file modified PSScriptTools.psd1
Binary file not shown.
47 changes: 24 additions & 23 deletions PSScriptTools.psm1
Expand Up @@ -3,33 +3,13 @@ Get-ChildItem -path $PSScriptRoot\*.ps1 | foreach-object -process {
. $_.FullName
}

$aliases = @()
$aliases+= Set-Alias -Name Tee-Verbose -Value Out-VerboseTee -PassThru
$aliases+= Set-Alias -Name occ -Value Out-ConditionalColor -PassThru
$aliases+= Set-Alias -Name pswho -Value Get-PSWho -PassThru
$aliases+= Set-Alias -Name cc -Value Copy-Command -PassThru
$aliases+= Set-Alias -Name fv -Value Format-Value -PassThru
$aliases+= Set-Alias -Name fp -value Format-Percent -PassThru
$aliases+= Set-Alias -name fs -value Format-String -PassThru
$aliases+= Set-Alias -Name om -Value Out-More -PassThru
$aliases+= Set-Alias -name ibx -value Invoke-InputBox -PassThru

$exportParams = @{
Function = 'Add-Border','Tee-Verbose','Write-Detail','Out-VerboseTee',
'Get-PSWho','Out-ConditionalColor','New-RandomFileName','New-CustomFileName',
'Copy-Command','Format-Value','Format-String','Format-Percent','Get-PSLocation',
'Get-PowerShellEngine','Out-More','Invoke-Inputbox'
Alias = $aliases.Name
}
Export-ModuleMember @exportParams

#add ToDo options to the ISE or VS Code
if ($psEditor) {
$sb = {
Param(
[Microsoft.PowerShell.EditorServices.Extensions.EditorContext]$context
)

Add-Type -AssemblyName "microsoft.visualbasic" -ErrorAction Stop
$prompt = "What do you need to do?"
$title = "To Do"
$item = Invoke-Inputbox -Title $title -Prompt $prompt
Expand All @@ -41,16 +21,37 @@ if ($psEditor) {
}
elseif ($psise) {
$action = {
Add-Type -AssemblyName "microsoft.visualbasic" -ErrorAction Stop

$prompt = "What do you need to do?"
$title = "To Do"
$item = Invoke-Inputbox -Title $title -Prompt $prompt
$todo = "# [$(Get-Date)] TODO: $item"
$psise.CurrentFile.Editor.InsertText($Todo)
$psise.CurrentFile.Editor.InsertText($todo)
#jump cursor to the end
$psise.CurrentFile.editor.SetCaretPosition($psise.CurrentFile.Editor.CaretLine,$psise.CurrentFile.Editor.CaretColumn)
}

#add the action to the Add-Ons menu
$psISE.CurrentPowerShellTab.AddOnsMenu.Submenus.Add("ToDo",$Action,"Ctrl+Alt+2" ) | Out-Null
}

$aliases = @()
$aliases+= Set-Alias -Name Tee-Verbose -Value Out-VerboseTee -PassThru
$aliases+= Set-Alias -Name occ -Value Out-ConditionalColor -PassThru
$aliases+= Set-Alias -Name pswho -Value Get-PSWho -PassThru
$aliases+= Set-Alias -Name cc -Value Copy-Command -PassThru
$aliases+= Set-Alias -Name fv -Value Format-Value -PassThru
$aliases+= Set-Alias -Name fp -Value Format-Percent -PassThru
$aliases+= Set-Alias -Name fs -Value Format-String -PassThru
$aliases+= Set-Alias -Name om -Value Out-More -PassThru
$aliases+= Set-Alias -Name ibx -Value Invoke-InputBox -PassThru

$exportParams = @{
Function = 'Add-Border','Tee-Verbose','Write-Detail','Out-VerboseTee',
'Get-PSWho','Out-ConditionalColor','New-RandomFileName','New-CustomFileName',
'Copy-Command','Format-Value','Format-String','Format-Percent','Get-PSLocation',
'Get-PowerShellEngine','Out-More','Invoke-Inputbox'
Alias = $aliases.Name
}
Export-ModuleMember @exportParams

26 changes: 23 additions & 3 deletions README.md
Expand Up @@ -9,6 +9,11 @@ You can also install this from the PowerShell Gallery:
```
Install-Module PSScriptTools
```
or in PowerShell Core:
```
Install-Module PSScriptTools -scope currentuser
```


Please post any questions, problems or feedback in Issues. Any input is greatly appreciated.

Expand Down Expand Up @@ -153,8 +158,10 @@ PS C:\> format-value 1235465676 -Unit kb
A simple function to get common locations. This can be useful with cross-platform scripting.

![](./images/pslocation-win.png)

![](./images/pslocation-linux.png)


## Get-PowerShellEngine
Use this command to quickly get the path to the PowerShell executable. In Windows you should get a result like this:
```
Expand All @@ -163,14 +170,25 @@ C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
```
But PowerShell Core is a bit different:
```
PS /home/jhicks> Get-PowerShellEngine /opt/microsoft/powershell/6.0.0-rc/pwsh
PS /home/jhicks> Get-PowerShellEngine
/opt/microsoft/powershell/6.0.0-rc/pwsh
```

You can also get detailed information.
![Windows PowerShell](./images/get-powershellengine1.png)

![PowerShell Core on Windows](./images/get-powershellengine2.png)

![PowerShell Core on Linux](./images/get-powershellengine3.png)

Results will vary depending on whether you are running Windows PowerShell or PowerShell Core.
## Out-More
This command provides a PowerShell alternative to the cmd.exe MORE command, which doesn't work in the PowerShell ISE. When you have screens of information, you can page it with this function.
```
get-service | out-more
```
![](./images/out-more.png)

This also works in PowerShell Core.

## Invoke-InputBox
Expand All @@ -187,17 +205,19 @@ Invoke-Inputbox -Prompt "Enter a password for $Name" -AsSecureString -Background
![](./images/ibx-2.png)

This example also demonstrates that you can change form's background color.
This function will not work in PowerShell Core.
This function will **not** work in PowerShell Core.

## ToDo
Because this module is intended to make scripting easier for you, it adds options to insert ToDo statements into PowerShell files. If you are using the PowerShell ISE or VS Code and import this module, it will add the capability to insert a line like this:
```
# [12/13/2017 16:52:40] TODO: Add parameters
```
In the PowerShell ISE, you will get a new menu under Add-Ons

![](./images/todo-1.png)

You can use the menu or keyboard shortcut which will launch an input box.

![](./images/todo-2.png)

The comment will be inserted at the current cursor location.
Expand All @@ -206,4 +226,4 @@ In VS Code, access the command palette (Ctrl+Shift+P) and then "PowerShell: Show
### 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.

*last updated 13 December 2017*
*last updated 14 December 2017*
3 changes: 1 addition & 2 deletions Utilities.ps1
Expand Up @@ -256,5 +256,4 @@ Function Invoke-InputBox {

}




4 changes: 4 additions & 0 deletions changelog.txt
@@ -1,5 +1,9 @@
#Changelog for PSScriptTools

v1.1.0
Cleaned up ToDo code (Issue #12)
Updated README

v1.0.1
fixed version number mistake
updated README.md
Expand Down
2 changes: 1 addition & 1 deletion docs/Out-ConditionalColor.md
Expand Up @@ -70,7 +70,7 @@ Get all services where the displayname starts with windows and display stopped s
PS C:\> get-service -displayname windows* | out-conditionalcolor @{Stopped='Red'} status -ov winstop
```

Repeat the previous example, but also save the output to the variable winstop. When you look at $Winstop you'll see the services, but they won't be coloredized. This exampleExamples uses the parameters positionally.
Repeat the previous example, but also save the output to the variable winstop. When you look at $Winstop you'll see the services, but they won't be coloredized. This example uses the parameters positionally.

### EXAMPLE 3
```
Expand Down
Binary file added images/get-powershellengine1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/get-powershellengine2.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/get-powershellengine3.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 30303ba

Please sign in to comment.