Do You Know Write-Output?

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!


Posted Oct 01 2010, 08:00 AM by ps1
Concentrated Tech NSoftware Dell Compellent Sponsored by Idera and Concentrated Tech and NSoftware and Dell Compellent
Copyright 2011 PowerShell.com. All rights reserved.