如何在PowerShell(1.0或2.0)中注释掉代码?
当前回答
是#。
关于特殊字符,请参见PowerShell -特殊字符和令牌。
其他回答
在PowerShell ISE中,您可以按Ctrl+J打开开始剪辑菜单并选择注释块:
在PowerShell V1中,只有#使注释后面的文本成为注释。
# This is a comment in PowerShell
在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 (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
{}
有关. synopsis和.*的更多解释,请参阅about_Comment_Based_Help。
注意:这些函数注释由Get-Help CmdLet使用,可以放在关键字function之前,或者放在代码本身之前或之后的{}内部。
是#。
关于特殊字符,请参见PowerShell -特殊字符和令牌。
你可以做:
(Some basic code) # Use "#" after a line and use:
<#
for more lines
...
...
...
..
.
#>
Here
# Single line comment in PowerShell
<#
--------------------------------------
Multi-line comment in PowerShell V2+
--------------------------------------
#>
推荐文章
- 增强的for循环中的Null检查
- 如何在PowerShell中获得本地主机名?
- 如何从同一个YAML文件的其他地方引用YAML“设置”?
- PowerShell:如何将数组对象转换为PowerShell中的字符串?
- 从PowerShell ISE中的另一个PS1脚本调用PowerShell脚本PS1
- 如何运行一个PowerShell脚本而不显示窗口?
- PowerShell:仅为单个命令设置环境变量
- 在VS Code中禁用“Comments are not allowed In JSON”错误
- 是否有一种方法可以通过双击.ps1文件来使PowerShell脚本工作?
- Swift:理解// MARK
- 把if-elif-else语句放在一行中?
- 在构建中编写注释的语法是什么?gradle文件?
- PowerShell等价于grep -f
- “Write-Host”,“Write-Output”,或“[console]::WriteLine”之间的区别是什么?
- Javascript函数前导bang !语法