Chain commands on the PowerShell command line (like POSIX sh &&)

conditional-statements, powershell, powershell-2.0, shell

Solution

There is no direct analog to && or ||. There are several discussions on alternatives though. Here is one example:

conditional execution (&& and ||) in powershell

Problem

Does PowerShell have an equivalent to this command construct from `sh` (and derivatives): ``` $ cmd1 && cmd2 ``` where `cmd2` is only run when `cmd1` exits sucessfully? I know you can combine commands with a semicolon. However, this disregards the exit status of commands.

Original source

Related problems