К НЕ используйте -verbose
, но переключатель:
function get-object{
param (
[switch]$gassy
)
"switch gassy is {0}" -f $gassy
}
> get-object
switch gassy is False
> get-object -gassy
switch gassy is True
См. Get-Help about_commonparameters
-Verbose [: {$ true |$ false}] Псевдоним: vb
Displays detailed information about the operation performed by the
command. This information resembles the information in a trace or in
a transaction log. This parameter works only when the command generates
a verbose message. For example, this parameter works when a command
contains the Write-Verbose cmdlet.
The Verbose parameter overrides the value of the $VerbosePreference
variable for the current command. Because the default value of the
$VerbosePreference variable is SilentlyContinue, verbose messages
are not displayed by default.
Valid values:
$true (-Verbose:$true) has the same effect as -Verbose.
$false (-Verbose:$false) suppresses the display of verbose
messages. Use this parameter when the value of $VerbosePreference
is not SilentlyContinue (the default).