- Getting Started with PowerShell
- Michael Shepard
- 292字
- 2021-07-16 20:28:19
PowerShell aliases
If you tried to use DIR
and CD
in the last section, you may have noticed that they didn't work exactly as the DOS commands that they resemble. In case you didn't see this, enter DIR
/S
on a PowerShell prompt and see what happens. You will either get an error complaining about a path not existing, or get a listing of a directory called S
. Either way, it's not the listing of files including subdirectories. Similarly, you might have noticed that CD
in PowerShell allows you to switch between drives without using the /D
option and even lets you change to a UNC path. The point is that, these are not DOS commands. What you're seeing is a PowerShell alias.
Aliases in PowerShell are alternate names that PowerShell uses for both PowerShell commands and programs. For instance, in PowerShell, DIR
is actually an alias for the Get-ChildItem
cmdlet. The CD
alias points to the Set-Location
cmdlet. Aliases exist for many of the cmdlets that perform operations similar to the commands in DOS, Linux, or Unix shells. Aliases serve two main purposes in PowerShell, as follows:
- They allow more concise code on Command Prompt
- They ease users' transition from other shells to PowerShell
To see a list of all the aliases defined in PowerShell, you can use the Get-Alias
cmdlet. To find what an alias references, type Get-Alias
<alias>. For example, see the following screenshot:

To find out what aliases exist for a cmdlet, type Get-Alias –Definition
<cmdlet> as follows:

Here we can see that the Get-ChildItem
cmdlet has three aliases. The first and last assist in transitioning from DOS and Linux shells, and the middle one is an abbreviation using the first letters in the name of the cmdlet.
- 一步一步學Spring Boot 2:微服務項目實戰
- HTML5移動Web開發技術
- Android應用程序開發與典型案例
- Mastering Concurrency in Go
- Learning RabbitMQ
- Django開發從入門到實踐
- 微信小程序入門指南
- The DevOps 2.5 Toolkit
- Mastering JavaScript High Performance
- Lighttpd源碼分析
- 計算機應用基礎教程(Windows 7+Office 2010)
- Python預測分析與機器學習
- SFML Game Development
- MongoDB Administrator’s Guide
- 現代C++語言核心特性解析