PowerShell Learning notes-Run command

Source: Internet
Author: User
Tags naming convention

When it comes to "Shell," it's easy to connect with scripts, programming languages, and so on, which is why many ITPro don't delve into PowerShell. Many ITPro think that it is probably a misunderstanding to use PowerShell to involve complex functions, variables, and scripts. In fact, the purpose of PowerShell design is to be used as an advanced management tool for system administrators. Therefore, the purpose of running the command to achieve the management system is the beginning of our learning PowerShell.

First, what is a cmdlet

The Cmdlet is a native PowerShell command-line tool that, while seemingly similar to normal Dos command-line tools, is fundamentally different. Cmdlets are much more complex than pure Dos command-line commands. Dos command-line commands can be executed in the console window of PowerShell, or vice versa.

650) this.width=650; "src=" Http://image.135editor.com/files/users/101/1012296/201701/Wrndvnxx_frW7.png "alt=" Screen Shot 2017-01-06 at 09.55.37.png "/>

These are the results of executing the "get-command" command in the PowerShell console and the Dos console, respectively. As you can see, the left window has result feedback, and the Dos window on the right is not able to find the command information. What would happen if we tried to execute a Dos command?

650) this.width=650; "src=" Http://image.135editor.com/files/users/101/1012296/201701/yEJSC87A_fIwT.png "alt=" Screen Shot 2017-01-06 at 10.00.10.png "/>

Ii. naming conventions for cmdlets

There are no rules inadequate surrounding area, and so is PowerShell's Cmdlet. All Cmdlet commands are made up of "verb" + "-" + "noun (singular form)", for example: get (verb)-(dash) command (noun). You can view the list of verbs that are allowed by running Get-verb.

650) this.width=650; "Src=" http://image2.135editor.com/cache/remote/ Ahr0chm6ly9tbwjpei5xbg9nby5jbi9tbwjpel9wbmcvwkjpyuj5mgv5mllkdwljsnrtdllzvuj0dxlyc1p0vkveeljqtmzzm1hovhfkadl2zhblcwvcafnhr Zdpyzbdcuduynbxy1pmzdjxwmjmbxreywlhem9xylp3lza= "alt=" screen Shot 2017-01-06 at 10.14.06.png "/>

PowerShell allows custom nouns, so there is no Get-noun Cmdlet to display all nouns. It is important to note that not all verb positions are verbs, such as New, Where, which are verb-like nouns (if you do not understand, please fill in the English course).

The biggest benefit of this naming convention is that you can pre-guess the command and then use the Help system or the Get-command command to verify it.

Third, alias

Although we have mastered the naming conventions of PowerShell, we find that some of the commands in use are too long to be used in order to do so, which is why you need to "alias". To see if a Cmdlet command has an alias, execute the following command: Get-alias-definition "Get-service"

650) this.width=650; "Src=" http://image2.135editor.com/cache/remote/ Ahr0chm6ly9tbwjpei5xbg9nby5jbi9tbwjpel9wbmcvwkjpyuj5mgv5mllkdwljsnrtdllzvuj0dxlyc1p0vkveenvrded4refuu0ezm2y4snh0q0tlzznlu jhpyuw2svi5vkzbvlm2whkxvnz0a0lyd2vuddrim1evma== "alt=" screen Shot 2017-01-06 at 10.26.31.png "/>

You can see that GSV is an alias for Get-service. You can also create a custom alias with the New-alias command, but if you do not export it, the lifecycle is limited to this session.

Iv. some of the terms

Cmdlets: Native PowerShell command-line tools exist only in PowerShell and in. Net Framework languages like C #. Pronunciation: Command-let.

Function: Similar to a Cmdlet, is written in PowerShell's own scripting language.

Workflow (Workflow): A special type of function that is embedded in the PowerShell workflow execution system.

Application: Is any type of external executable program, including command-line tools like Ping, Ipconfig, and so on.

"Command": is a generic term that represents any or all of the above mentioned terms.



This article from the "China Polar Road" blog, reproduced please contact the author!

PowerShell Learning notes-Run command

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.