Do You Know Write-Output?

by Oct 1, 2010

When you leave data behind, PowerShell automatically returns it to the caller. This may create strange-looking code. With Write-Output, you can explicitly assign your return values. These two examples work the same:

Function testA {
'My Result'
}
Function testB {
Write-Output 'My Result'
}

Twitter This Tip! ReTweet this Tip!