Automating the world one-liner at a time…
PSMDTAG:FAQ: Why don't I see output when I use Write-Verbose and Write-Debug?PSMDTAG:SHELL: Use of Preference Variables to control behavior of streams.
In Windows PowerShell, the WRITE-XXX cmdlets merely sends things to a Named stream. You then have user-defined preferences for what to do when things appear on that stream. Alex Angelopoulos provided the following function TEST-WRITER to highlight the issue:
function Test-Writer { 'Will test Write -Host, -Output, -Verbose, -Warning, -Error.' Write-Host 'Write-Host' Write-Output 'Write-Output' Write-Verbose 'Write-Verbose' Write-Warning 'Write-Warning' Write-Error 'Write-Error' 'Done with test.' }PS> test-writerWill test Write -Host, -Output, -Verbose, -Warning, -Error.Write-HostWrite-OutputWARNING: Write-WarningTest-Writer : Write-ErrorAt line:1 char:11+ test-writer <<<<Done with test.
Notice the lack of "Write-Verbose" and "Write-Debug"
PS> dir variable:*preferenceName Value---- -----DebugPreference SilentlyContinueVerbosePreference SilentlyContinueProgressPreference ContinueErrorActionPreference ContinueWhatIfPreference 0WarningPreference ContinueConfirmPreference HighPS> $DebugPreference=$VerbosePreference="Continue"PS> test-writerWill test Write -Host, -Output, -Verbose, -Warning, -Error.Write-HostWrite-OutputVERBOSE: Write-VerboseWARNING: Write-WarningTest-Writer : Write-ErrorAt line:1 char:11+ test-writer <<<<Done with test.PS>
Enjoy!
Jeffrey Snover [MSFT]Windows PowerShell ArchitectVisit the Windows PowerShell Team blog at: http://blogs.msdn.com/PowerShellVisit the Windows PowerShell ScriptCenter at: http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx