&& Equivalent in Powershell

Possible duplicates:
What is the PowerShell equivalent for Bash && & && and || operators?
Can I get && to work in Powershell?

In bash, I use ./task1.sh && ./task2.shtask1 to run, and then run task2 until task1 returns an error code. When I try .\task1.bat && .\task2.batin Powershell, I get the error message "Token && is not a valid delimiter in this version."

Is there an equivalent for && in Windows Powershell?

+3
source share
2 answers

This is the closest I can get:

  .\task1.ps1 ; if($?){.\task2.ps1}
+12
source

I think the closest equivalent is:

.\task1.bat;if($lastexitcode -eq 0){.\task2.bat}

, Powershell -and, , .

+2

All Articles