In Win command line, you can do cmd1 && cmd2 and cmd2 will only be executed if cmd1 succeeded. I think the powershell equivalent, based on other answers here, would be (cmd1) -and (cmd2). However, I'm seeing weird behavior when testing it - specifically, I'm getting a fail when I should be getting true. Here's a minimal replicating example.
PS>(Start-Sleep 1)
PS>$?
True
PS>(Start-Sleep 1) -and (Start-Sleep 1)
False
PS>$?
True
PS>$z = (Start-Sleep 1) -and (Start-Sleep 1)
False
PS>$z
False
PS>$?
True
Why are the sleeps failing to chain, and why is $z not matching $??