Figured it out by myself. Here goes:
I prefixed the Invoke command with a variable assignment and showed that variable when an error is reported by $LastExitCode.
$TSMcmd = ".\tsm maintenance cleanup -x"
$ReturnInfo = Invoke-Expression -Command:$TSMcmd
if($LastExitCode -eq 1)
This results in a popup window with the text "Unrecognized option: -x".
If possible can you share powerShell script