Search notes:

PowerShell: Pipeline Chain Operators

The pipeline chain operators are && and ||. They differ from other operators in that they connect two pipelines rather than are being used in expressions.
&& runs the next pipeline if the previous failed succeed, || runs the second pipeline if the previous one failed.
If a pipeline is considered successful is determined by the value of $? (and $lastExitCode ?).
The first pipeline is successful, the second one is not run:
write-host 'first pipeline' || write-host 'second pipeline'
The first pipeline is successful, so the seoncd on is run as well:
write-host 'first pipeline' && write-host 'second pipeline'
The first pipeline fails, so the second one is executed:
no-such-command || write-host 'second pipeline'
The first pipeline fails, so the second one is not executed. (Note, if $errorActionPreference is set to stop, the second pipeline is not run when the first pipeline fails).
no-such-command && write-host 'second pipeline'

See also

The call operator (&)

Index