Running a Powershell script with some Box CLI commands in it. The commands complete successfully and the result is shown on screen/in the Powershell console, but I can't seem to get that result into a variable so the script can determine success/failure and continue processing accordingly.
Specifically, I'm working with the command: Box collaborations:delete
I've tried:
$X = box collaborations:delete $CollabID --as-user $UserID --json
box collaborations:delete $CollabID --as-user $UserID --json > $X
$X = "$(box collaborations:delete $CollabID --as-user $UserID --json)" | ConvertFrom-Json
In all 3 cases $X is null/empty, but "Collaboration <CollabID> successfully removed" is shown on the screen in the Powershell console.
How do I get the "Collaboration <CollabID> successfully removed" in a variable?