Q:

Capturing Non-Standard Powershell CmdLet Output for Flow Control

Currently trying to build a script utilizing cmdlets from the MS released "Team Foundation Server Power Tools" package.
I'm attempting to flow command logic from the success or failure of the "Update-TfsWorkspace" cmdlet however I can't seem get a return code out of the call nor can I capture the output using Out-String.  I'm using Powershell v1.
update-tfsworkspace "C:\doesnotexist\" -recurse -version T

Yields a message of "Unable to determine the workspace." which is the error I'm trying to catch.
$ret = update-tfsworkspace "C:\doesnotexist\" -recurse -version T

Is expected to give me a $true/$false indicating success/fail but doesn't work.
update-tfsworkspace "C:\doesnotexist\" -recurse -version T | Out-Null

Is expected to prevent the cmdlet from writing the message but doesn't work.
trap{echo "fail"}
update-tfsworkspace $workspace_path -recurse -version T

Is expected to catch an error and write "fail" but doesn't work.
$msg = update-tfsworkspace $workspace_path -recurse -version T | Out-String

Is expected to populate a $msg variable with the host output but doesn't work.
I'm totally out of ideas here.  Help would be appreciated!

A:

Little hacky, but since I don't have TFS to try to figure something else out, see if this helps.

