Write-Host vs Write-Information in PowerShell 5
<p>It is well known that <code>Write-Host</code> is evil.
In <code>PowerShell 5</code>, <code>Write-Information</code> is added and is considered to replace <code>Write-Host</code>.</p>

<p>But, really, which is better?<br>
<code>Write-Host</code> is evil for it does not use pipeline, so the input message can't get reused.<br>
But, what <code>Write-Host</code> do is just to show something in the console right? In what case shall we reuse the input?<br>
Anyway, if we really want to reuse the input, why not just write something like this:</p>

<pre><code>$foo = "Some message to be reused like saving to a file"
Write-Host $foo
$foo | Out-File -Path "D:\foo.log"
</code></pre>

<p>Another Cons of <code>Write-Host</code> is that, <code>Write-Host</code> can specified in what color the messages are shown in the console by using <code>-ForegroundColor</code> and <code>-BackgroundColor</code>.</p>

<p>On the other side, by using <code>Write-Information</code>, the input message can be used wherever we want via the No.6 pipeline. And doesn't need to write the extra codes like I write above. But the dark side of this is that, if we want to write messages to the console and also saved to the file, we have to do this:</p>

<pre><code># Always set the $InformationPreference variable to "Continue"
$InformationPreference = "Continue";

# if we don't want something like this:
# ======= Example 1 =======
# File Foo.ps1
$InformationPreference = "Continue";
Write-Information "Some Message"
Write-Information "Another Message"

# File AlwaysRunThisBeforeEverything.ps1
.\Foo.ps1 6&gt;"D:\foo.log"
# ======= End of Example 1 =======

# then we have to add '6&gt;"D:\foo.log"' to every lines of Write-Information like this:
# ======= Example 2 =======
$InformationPreference = "Continue";
Write-Information "Some Message" 6&gt;"D:\foo.log"
Write-Information "Another Message" 6&gt;"D:\foo.log"
# ======= End of Example 2 =======
</code></pre>

<p>A little bit redundant I think.</p>

<p>I only know a little aspect of this "vs" thing, and there must have something out of my mind. So is there anything else that can make me believe that <code>Write-Information</code> is better than <code>Write-Host</code>, please leave your kind answers here.<br>
Thank you.</p>