0

In Bash,

command1.sh || recover.sh
command2.sh && command3.sh

Does powershell offer a similar, tight, construct?

The closest I have come up with:

command1.ps1; if ($? -ne 0) { recover.ps1 }
command2.ps1; if ($? -eq 0) { command3.ps1 }
3

1 Answer 1

2

Powershell 7 has it https://learn.microsoft.com/en-us/powershell/scripting/whats-new/what-s-new-in-powershell-70?view=powershell-7#pipeline-chain-operators

1/0 || 'no'
RuntimeException: Attempted to divide by zero.

no
Sign up to request clarification or add additional context in comments.

1 Comment

Now I just eagerly await PS7 at work :(

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.