Use Write-Cmdlets with Care!

by Sep 30, 2010

There is a fundamental difference between outputting data using Write-Host and just "leaving info behind":"

Function test {
Write-Host "Result A"
"Result B"

When you run the function, you will get back both results, but Write-Host always directly writes to the console. As such, So you cannot store this result in a variable to process it later.

Result A
Result B
$a = test
Result A
Result B

Twitter This Tip! ReTweet this Tip!