Sunday, February 11, 2018

Get Aliases for Often Used Commands

PowerShell provides aliases for many commands to save on typing. For example, the cmdlet "Get-Service" can be called with the alias 'gsv'.

But how can we know if a particular command or cmdlet even has an alias? Two ways:

First, use "Get-Alias" to see the entire list of aliases available:

Get-Alias

















Second, to save scrolling and squinting, we can narrow down that long list of aliases by using the -Definition switch for the command we want to investigate:

Get-Alias -Definition <cmdlet>



Scripter's Note: Aliases are useful for working on the command line, but when writing scripts, it's best practices to use the full command names. This makes it easier for yourself and for others to read the script.

No comments:

Post a Comment