I\'ve learned from this Stack Overflow question, that PowerShell return semantics are different, let\'s say, from C#\'s return semantics. Quote from the aforementioned quest
You can also just assign everything to null, and then return just the variable you want:
Function TestReturn { $Null = @( Write-Output "Hi there!" 1 + 1 $host $ReturnVar = 5 ) return $ReturnVar }