Skip to content

Instantly share code, notes, and snippets.

@dnasca
Last active August 29, 2015 14:20
Show Gist options
  • Select an option

  • Save dnasca/1956a1cf523f47f0c6f5 to your computer and use it in GitHub Desktop.

Select an option

Save dnasca/1956a1cf523f47f0c6f5 to your computer and use it in GitHub Desktop.
easy way to create aliases to run applications from the console
# 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