cmd/batch file could turn on and turn off "echo". So in PowerShell, I have a bunch of "write-host" output, I want somewhere to turn on / off write-host for debugging convenience.
Does PowerShell has such a function?
cmd/batch file could turn on and turn off "echo". So in PowerShell, I have a bunch of "write-host" output, I want somewhere to turn on / off write-host for debugging convenience.
Does PowerShell has such a function?
You should use Write-Verbose
instead of Write-Host
, this will make your debugging data controlled by the variable $VerbosePreference
. This variable has the same value set as $ErrorActionPreference
, and the default is SilentlyContinue
, which means that no verbose output is generated. You can set this to Continue
and then have your verbose output visible.
The
Set-PSDebug
cmdlet has-Trace <int>
parameter that can be used to same effect asecho on
.