PowerShell the method of single-line annotation, multiline annotation, block annotation _powershell

Source: Internet
Author: User

The PowerShell annotation character is divided into row and block annotation characters. A line annotation uses the pound sign (#) to cause a row, and a block annotation uses "<#" and "#>" to cause a comment.

Line annotation Character

Examples are as follows:

Copy Code code as follows:

# define a Count variable
$i = 0

Block annotation, multiline comment

Examples are as follows:

Copy Code code as follows:

<#
File: Xxx.ps1
Use: the XXX feature script for testing
Create: 2013-03-27,jb51.net
Modification: 2013-09-04,jb51.net
#>

This is a piece of content that will be defined for scripting purposes and instructions before each write script. It is in the form of annotations, recommended that everyone do so, to facilitate later know the function of the script, source, version, and so on.

About C # 's annotation characters

Although PowerShell scripts are heavily compliant with C # syntax rules, C # Annotation characters cannot be used in PowerShell.

Examples are as follows:

Copy Code code as follows:

PS c:\users\zhanghong>//111
The '//' item cannot be recognized as a cmdlet, function, script file, or the name of a running program. Check the spelling of the name, if the path is included, make sure the path is correct, and then try again.

About the use of PowerShell annotation, small series on the introduction so much, I hope to help you, thank you!

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.