在Powershell中添加多行注释



如何在powershell脚本中添加多行注释?

$a=10$b=20

令状主机";求和";

我们可以在powershell中添加多行注释,如下

<

$a=10

$b=20

令状主机";求和";

#>

是的,PowerShell支持多行块注释:

<#
$a=10
$b=20
Write-Host "Sum"
#>

请注意,块注释是不可嵌套的:

<# 
This is part of the comment
<#
$a=10
$b=20
Write-Host "Sum"
#>
But this is not...
#>

您可以使用<##>符号来创建注释块。

<#
$a=10
$b=20
writ-host "Sum"
#>

文件:https://learn.microsoft.com/en-us/powershell/scripting/developer/help/syntax-of-comment-based-help?view=powershell-7.1

最新更新