{"id":10071,"date":"2006-07-04T00:13:00","date_gmt":"2006-07-04T00:13:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/powershell\/2006\/07\/04\/use-of-preference-variables-to-control-behavior-of-streams\/"},"modified":"2019-02-18T13:21:35","modified_gmt":"2019-02-18T20:21:35","slug":"use-of-preference-variables-to-control-behavior-of-streams","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/powershell\/use-of-preference-variables-to-control-behavior-of-streams\/","title":{"rendered":"Use of Preference Variables to control behavior of streams"},"content":{"rendered":"<p>PSMDTAG:FAQ: Why don&#8217;t I see output when I use Write-Verbose and Write-Debug?<br \/>PSMDTAG:SHELL: Use of Preference Variables to control behavior of streams.<\/p>\n<p>In Windows PowerShell, the WRITE-XXX cmdlets merely sends things to a Named stream.&nbsp; You then have user-defined preferences for what to do when things appear on that stream.&nbsp; Alex Angelopoulos provided the following function TEST-WRITER to highlight the issue:<\/p>\n<p><font face=\"Courier New\" size=\"1\">function Test-Writer<br \/>&nbsp;&nbsp;&nbsp; {<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8216;Will test Write -Host, -Output, -Verbose, -Warning, -Error.&#8217;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Write-Host &#8216;Write-Host&#8217;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Write-Output &#8216;Write-Output&#8217;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Write-Verbose &#8216;Write-Verbose&#8217;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Write-Warning &#8216;Write-Warning&#8217;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Write-Error &#8216;Write-Error&#8217;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8216;Done with test.&#8217;<br \/>&nbsp;&nbsp;&nbsp; }<\/p>\n<p>PS&gt; <strong>test-writer<br \/><\/strong>Will test Write -Host, -Output, -Verbose, -Warning, -Error.<br \/>Write-Host<br \/>Write-Output<br \/>WARNING: Write-Warning<br \/>Test-Writer : Write-Error<br \/>At line:1 char:11<br \/>+ test-writer &lt;&lt;&lt;&lt;<br \/>Done with test.<\/font><\/p>\n<p>Notice the lack of &#8220;Write-Verbose&#8221; and &#8220;Write-Debug&#8221;<\/p>\n<p><font face=\"Courier New\" size=\"1\">PS&gt; <strong>dir variable:*preference<\/strong><\/p>\n<p>Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Value<br \/>&#8212;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212;&#8211;<br \/>DebugPreference&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SilentlyContinue<br \/>VerbosePreference&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SilentlyContinue<br \/>ProgressPreference&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Continue<br \/>ErrorActionPreference&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Continue<br \/>WhatIfPreference&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0<br \/>WarningPreference&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Continue<br \/>ConfirmPreference&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; High<\/p>\n<p>PS&gt; <strong><font color=\"#ff0000\">$DebugPreference=$VerbosePreference=&#8221;Continue&#8221;<br \/><\/font><\/strong>PS&gt; <strong>test-writer<br \/><\/strong>Will test Write -Host, -Output, -Verbose, -Warning, -Error.<br \/>Write-Host<br \/>Write-Output<br \/><font color=\"#ff0000\">VERBOSE: Write-Verbose<br \/>WARNING: Write-Warning<br \/><\/font>Test-Writer : Write-Error<br \/>At line:1 char:11<br \/>+ test-writer &lt;&lt;&lt;&lt;<br \/>Done with test.<br \/>PS&gt;<\/font><\/p>\n<p><font face=\"Courier New\" size=\"1\">Enjoy!<\/font><\/p>\n<p><font face=\"Courier New\" size=\"1\"><br \/>Jeffrey Snover [MSFT]<br \/>Windows PowerShell Architect<br \/>Visit the Windows PowerShell Team blog at:&nbsp;&nbsp;&nbsp; <a href=\"http:\/\/blogs.msdn.com\/PowerShell\">http:\/\/blogs.msdn.com\/PowerShell<\/a><br \/>Visit the Windows PowerShell ScriptCenter at:&nbsp; <a href=\"http:\/\/www.microsoft.com\/technet\/scriptcenter\/hubs\/msh.mspx\">http:\/\/www.microsoft.com\/technet\/scriptcenter\/hubs\/msh.mspx<\/a><\/font><\/p>\n","protected":false},"excerpt":{"rendered":"<p>PSMDTAG:FAQ: Why don&#8217;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.&nbsp; You then have user-defined preferences for what to do when things appear on that stream.&nbsp; Alex Angelopoulos provided the following function [&hellip;]<\/p>\n","protected":false},"author":600,"featured_media":13641,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[10,21],"class_list":["post-10071","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell","tag-faq","tag-shell"],"acf":[],"blog_post_summary":"<p>PSMDTAG:FAQ: Why don&#8217;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.&nbsp; You then have user-defined preferences for what to do when things appear on that stream.&nbsp; Alex Angelopoulos provided the following function [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/10071","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/users\/600"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/comments?post=10071"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/10071\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/media\/13641"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/media?parent=10071"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/categories?post=10071"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/tags?post=10071"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}