【发布时间】:2018-02-21 07:42:12
【问题描述】:
我在一个模块中编写了许多 powershell 函数。 每个函数都有 Write-verbose 。
例如:
function fun1{
# code
Write-verbose "Useful information from fun1"
}
function fun2{
# code
Write-verbose "Useful information from fun2"
}
现在当我使用该函数时,我必须为每个函数调用提及详细信息。
fun1 -params <paramvalue> -verbose
fun2 -params <paramvalue> -verbose
有没有办法为所有功能全局提及 Verbose?这样我就不必为每个函数提及冗长了。
【问题讨论】:
-
Check out this post of mine。
if (-not $PSBoundParameters.ContainsKey('Verbose')...将解决它,但需要修改您的函数。