如何在PowerShell中注释掉代码? [英] How do you comment out code in PowerShell?

查看:81
本文介绍了如何在PowerShell中注释掉代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

How do you comment out code in PowerShell (1.0 or 2.0)?

推荐答案

在在PowerShell V1中,只有可以在文本后添加注释。

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

# This is a comment in Powershell

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

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

#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 (jean-paul_blanc@silogix-fr.com)
    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
{}

有关。大纲和。* 参见 about_Comment_Based_Help

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

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.

这篇关于如何在PowerShell中注释掉代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆