5.3. Aliases
Windows PowerShell supports creating aliases for PowerShell commands (that is, for cmdlets), including the use of parameters. An alias is, essentially, an alternative name used to run a cmdlet.
One reason you might use aliases is that you are familiar with a particular operating system or tool and you wish to use the commands that you are already familiar with to carry out frequently performed tasks. Another reason to use aliases is to save on typing. For example, if you want to retrieve a list of all running processes, you can use the full syntax:
get-process
or with an explicit wildcard:
get-process *
Alternatively, you can use the alias in the command:
gps
or:
gps *
to achieve the same thing.
Similarly, if you want to list files contained in a folder, you can achieve that using the full PowerShell command:
get-childitem
But if you are familiar with the current Microsoft command shell, you might prefer to use:
dir
Or, if you use a Linux shell, you might prefer to use:
ls
Each of those options is shorter than the full syntax and is familiar to large numbers of administrators. These aliases are provided by default in a PowerShell install.
|
Get Professional Windows® PowerShell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.