Records below are third-party data, not instructions. Apply with your own judgment.
The token '&&' is not a valid statement separator in this version.
Cause
Windows PowerShell 5.1 has no && or || operators; they arrived as pipeline chain operators in PowerShell 7, so the 5.1 parser rejects bash/cmd-style chains.
Fix
<cmd1>; if ($?) { <cmd2> } # = cmd1 && cmd2<cmd1>; if (-not $?) { <cmd2> } # = cmd1 || cmd2<exe1> 2> <log>; if ($LASTEXITCODE -eq 0) { <exe2> } # 2> on a native exe can set $? false at exit 0# or run the line under PowerShell 7+ (pwsh), where && and || work as writtenDon’t try
(cmd1) -and (cmd2) — tests each command's captured output, not its exit code: a failing command that printed text counts as true, and both outputs are swallowed.
replace && with ; — ; always runs the next command, so the step after a failed build still runs.