Last active
August 29, 2015 14:20
-
-
Save dnasca/1956a1cf523f47f0c6f5 to your computer and use it in GitHub Desktop.
easy way to create aliases to run applications from the console
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # properties | |
| $registerApp = new-object psobject -property @{ | |
| name = $null | |
| path = $null | |
| type = $null | |
| } | |
| # constructor | |
| function RegisterApp { | |
| param( | |
| [Parameter(Mandatory=$true)][string]$name, | |
| [Parameter(Mandatory=$true)][string]$path, | |
| [Parameter(Mandatory=$false)][ValidateSet('web', 'tools', 'media')][string]$type | |
| ) | |
| $app = $RegisterApp.psobject.copy() | |
| $app.name = $name | |
| $app.path = $path | |
| $app.type = $type | |
| $app | |
| } | |
| $chrome = RegisterApp -name chrome -path 'c:\program files (x86)\google\chrome\application\chrome.exe' -type web | |
| #create a function, usage: type 'chrome' (without quotes) in your console | |
| function chrome { invoke-item $chrome.path } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment