First few lines of the link answers that question:
cmd1; if ($?) { cmd2 } = cmd1 && cmd2
cmd1; if (-not $?) { cmd2 } = cmd1 || cmd2
Just your usual Powershell verboseness.
Their logical operators page says it also supports -and and -or. I can't tell if "cmd1 -and cmd2" would have already worked. It sounds like unadorned "cmd1" didn't return the equivalent of $? before this PR.
No it wouldn’t work, cmd1 would return the stdout output of cmd1 if you could do that at all, but it would really try to use -and cmd2 as parameters to cmd1.
Interesting. Switching back and forth from Powershell and bash must be hard. Also $? has the exact opposite meaning in a Unix shell. $? as zero indicates success.
The problem is that many old utilities in Windows don't use the exit code to indicate failure. PowerShell cmdlets have exceptions that can be caught with `try`/`catch`, and there's `-ErrorAction Stop`, but there was no good solution for native commands.
It was supported with an if statement, but attempts to use && and || as operators gave an error that the syntax was not yet supported.