官术网_书友最值得收藏!

Discovering cmdlets and aliases

If you are new to PowerShell, you must be excited to know about all the cmdlets and aliases available. It is an easy language to read and learn. You might want to know how many cmdlets and aliases are out there that you can use in your scripting language. Wait, that's very simple. You can unleash the list of all cmdlets and aliases just using a couple of commands. Get-Command is the cmdlet that will list you all the available cmdlets:

PS C:\>Get-Command

You can further narrow down the discovery using some keyword, and this is major plus point, which lets you quickly search and use the appropriate cmdlet in your script. You do not need to remember any cmdlet; just think of a specific action or service that you want to do, and pass it on to the Get-Command cmdlet to further refine the search. If you want to list all the process-related cmdlets, then you can use this:

PS C:\>Get-Command *process*

Once you see the available list, you can pick up the most appropriate one and get help using the Get-Help cmdlet. This is the best way to learn about various cmdlets. There is nothing like a fixed set of cmdlets available. This list is growing everyday. As and when you add a module, a new set of cmdlets associated with the service or product will be added in the list. Moving further, when we install AWS Tools for PowerShell, a new set of cmdlets will be added, and we will be making use of this new set of cmdlets to work with AWS Cloud.

Another way you can work with commands inside PowerShell is via aliases. Aliases are how you can bridge your knowledge about cmdlets, where you are coming from to where you want to go inside of PowerShell. For example, Get-ChildItem is the cmdlet used for listing all the items in the present working directory, or you can specify the location. If you are a Windows guy, using dir for quite a long time, you may prefer to continue to use this instead of using Get-ChildItem. If you are a Linux guy, then you may prefer to use ls. So, if you type dir, ls, or gci at the command prompt, then all of them will lead to the same result as thrown by Get-ChildItem. Are dir, ls, and gci different commands? The answer is NO. dir, ls, and gci are the aliases for Get-ChildItem. So, if you type Get-Alias in the command prompt, it will list you all the aliases defined in the PowerShell. You can also create your own aliases using Set-Alias. To get the list of existing alias, you can run the following command:

PS C:\>Get-Alias

You can specify the name of the alias with Get-Alias to know the parent cmdlet; for example:

PS C:\>Get-Alias dir
PS C:\>Get-Alias ls
PS C:\>Get-Alias gci
主站蜘蛛池模板: 伊宁市| 布尔津县| 凤台县| 泗洪县| 上栗县| 全南县| 天台县| 佛教| 内江市| 广水市| 军事| 郑州市| 滨海县| 东乡族自治县| 外汇| 株洲县| 沙田区| 启东市| 民权县| 陆良县| 奈曼旗| 青阳县| 灌阳县| 阿勒泰市| 鹿泉市| 芮城县| 正镶白旗| 清徐县| 子洲县| 库尔勒市| 翁牛特旗| 政和县| 万年县| 遵义市| 宜兰县| 姚安县| 新邵县| 剑阁县| 博野县| 象山县| 宜丰县|