debugging - Powershell don't pass Verbosity level to called functions -
consider following script:
function a{ [cmdletbinding()] param() write-verbose "a verbose" write-host "a normal" } function b{ [cmdletbinding()] param() write-verbose "b verbose" write-host "b normal" } b -verbose
if invoke function 'b' verbose parameter switch specified, function 'a' (that called in 'b') called implicit verbose parameter. there way avoid this? (in other words, call 'b' verbose switch , 'a' without it).
if want suppress verbose output a
outside function b
, can use $psdefaultparametervalues
variable, starting powershell v3.
function a{ [cmdletbinding()] param() write-verbose "a verbose" write-host "a normal" } function b{ [cmdletbinding()] param() write-verbose "b verbose" write-host "b normal" } $psdefaultparametervalues['a:verbose'] = $false b -verbose
for powershell v2, have set verbose $false
when call a
b
function.
function b{ [cmdletbinding()] param() write-verbose "b verbose" write-host "b normal" -verbose:$false }
Comments
Post a Comment