title: Execute process conditionally in Windows PowerShell (e.g. the && and || operators in Bash)
body: <p>I'm wondering if anybody knows of a way to conditionally execute a program depending on the exit success/failure of the previous program.  Is there any way for me to execute a program2 immediately after program1 if program1 exits successfully without testing the LASTEXITCODE variable?  I tried the -band and -and operators to no avail, though I had a feeling they wouldn't work anyway, and the best substitute is a combination of a semicolon and an if statement.  I mean, when it comes to building a package somewhat automatically from source on Linux, the &amp;&amp; operator can't be beaten:</p>
  
  <pre><code># Configure a package, compile it and install it
  ./configure &amp;&amp; make &amp;&amp; sudo make install
  </code></pre>
  
  <p>PowerShell would require me to do the following, assuming I could actually use the same build system in PowerShell:</p>
  
  <pre><code># Configure a package, compile it and install it
  .\configure ; if ($LASTEXITCODE -eq 0) { make ; if ($LASTEXITCODE -eq 0) { sudo make install } }
  </code></pre>
  
  <p>Sure, I could use multiple lines, save it in a file and execute the script, but the idea is for it to be concise (save keystrokes).  Perhaps it's just a difference between PowerShell and Bash (and even the built-in Windows command prompt which supports the &amp;&amp; operator) I'll need to adjust to, but if there's a cleaner way to do it, I'd love to know.</p>