Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
509 views
in Technique[技术] by (71.8m points)

powershell - 你如何在PowerShell中注释掉代码?(How do you comment out code in PowerShell?)

你如何在PowerShell(1.0或2.0)中注释掉代码?

  ask by labyrinth translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

In PowerShell V1 there's only # to make the text after it a comment.

(在PowerShell V1中,只有#才能在评论后生成文本。)

# This is a comment in Powershell

In PowerShell V2 <# #> can be used for block comments and more specifically for help comments.

(在PowerShell V2中, <# #>可用于块注释,更具体地用于帮助注释。)

#REQUIRES -Version 2.0

<#
.SYNOPSIS
    A brief description of the function or script. This keyword can be used
    only once in each topic.
.DESCRIPTION
    A detailed description of the function or script. This keyword can be
    used only once in each topic.
.NOTES
    File Name      : xxxx.ps1
    Author         : J.P. Blanc ([email protected])
    Prerequisite   : PowerShell V2 over Vista and upper.
    Copyright 2011 - Jean Paul Blanc/Silogix
.LINK
    Script posted over:
    http://silogix.fr
.EXAMPLE
    Example 1
.EXAMPLE
    Example 2
#>
Function blabla
{}

For more explanation about .SYNOPSIS and .* see about_Comment_Based_Help .

(有关.SYNOPSIS.*更多说明,请参阅about_Comment_Based_Help 。)

Remark: These function comments are used by the Get-Help CmdLet and can be put before the keyword Function , or inside the {} before or after the code itself.

(备注:这些函数注释由Get-Help CmdLet使用,可以放在关键字Function之前,也可以放在代码本身之前或之后的{}内。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...