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

Comment blocks

The first recommendation is to create comment blocks for detailed tracking information about the PowerShell script itself. Comment blocks can track information about the script's creation, authors, changes, and other useful information that will enable you to quickly determine what the script is doing. PowerShell has built-in comment block support which integrates with the get-help cmdlet.

The required components include the following:

  1. Comment block location: The comment block must be the first item defined at the top of your script. If you use parameter blocks, you specify the parameter blocks after the comment block.
  2. Start comment block: In order to integrate with the help system, you need to specify the starting of the comment block. To start a comment block, you type <#.
  3. .SYNOPSIS: To create a synopsis for the script, type .SYNOPSIS on a line, and then on a subsequent line type a one-line description of why the script is being created.
  4. .DESCRIPTION: To create a full description for the script, type .DESCRIPTION on a line, and then on a subsequent line type a description of the script's functions so that any editor of the script will know the script's basic function. If it is a complicated script or a script that invokes other scripts, describe the overall process for it. You may also want to include author information that contains the author's name, author's position, author's company, contact information, initial release number, and date of the initial release.
  5. .PARAMETER: To provide parameter information that can be used while running the script, you can type .PARAMETER, and specify the parameter name. On a subsequent line, type a description of that parameter. If you have multiple parameters, you can define multiple .PARAMETER statements referencing parameter names.
  6. .EXAMPLE: To provide an example of usage for your script, you can type .EXAMPLE and provide an example on how to run the script from a command line. If you have multiple examples, you can define multiple .EXAMPLE statements.
  7. .NOTES: To provide notes for execution caveats, you can type .NOTES, and on a subsequent line type a usage note to execute the script.
  8. .LINK: If you have other help topics you want to link to, you can type .LINK, and on a subsequent line provide a URL to another help topic.
  9. Ending comment block: In order to integrate with the help system, you need to specify the ending of the comment block. To end a comment block, you type #>.

The following screenshot displays a proper comment block that will integrate with the help system:

Comment blocks

This properly shows the syntax of a comment block that is usable via the PowerShell help system. You start by first defining the commend block with <#. You then create a .SYNOPSIS section with a synopsis of the script. Then you create a .DESCRIPTION section and provide a detailed description of the script. You also provide details regarding the author, revision, and editing revisions to the script. Following that section, you define a .PARAMETER PATH section, which provides detailed information about the .PARAMETER PATH in the script. Next, you create an .EXAMPLE section, to provide an example for usage, and you create a .NOTES section to provide information about the required execution environment. You then close the comment block by issuing #>.

主站蜘蛛池模板: 陆川县| 砚山县| 怀仁县| 明水县| 商洛市| 呼玛县| 防城港市| 石楼县| 滨海县| 抚松县| 崇阳县| 蕲春县| 邵东县| 垫江县| 奈曼旗| 长葛市| 隆林| 罗平县| 湘潭市| 金堂县| 板桥市| 多伦县| 兴业县| 宝山区| 象山县| 阳山县| 芦山县| 石景山区| 崇义县| 罗平县| 长春市| 尤溪县| 阿坝县| 三门峡市| 灵山县| 嘉祥县| 高邮市| 香河县| 隆子县| 龙海市| 连南|