【发布时间】:2023-04-06 03:08:01
【问题描述】:
我已将一些 ecmet 替换为:
Write-Verbose "Doing somthing..."
我通过 PS ISE 运行我的脚本,例如:
.\FooScript.ps1 -verbose
但在输出窗口中我没有看到任何这些消息。
如何显示 write-Verbose 消息?
【问题讨论】:
标签: .net powershell powershell-ise verbose
我已将一些 ecmet 替换为:
Write-Verbose "Doing somthing..."
我通过 PS ISE 运行我的脚本,例如:
.\FooScript.ps1 -verbose
但在输出窗口中我没有看到任何这些消息。
如何显示 write-Verbose 消息?
【问题讨论】:
标签: .net powershell powershell-ise verbose
你需要添加
[CmdletBinding()]
在脚本的开头并使用
-verbose
查看详细消息的参数。
阅读更多打字:
help about_functions_advanced
【讨论】:
param() 声明之前。如果您没有参数,请将其添加为 param() 在 [CmdletBinding()] 之后
[CmdletBinding()] 调用具有 [CmdletBinding()] 的函数,则它必须有效!