I want my PowerShell script to stop when any of the commands I run fail (like set -e in bash). I\'m using both Powershell commands (New-Object System.Net.
set -e
New-Object System.Net.
You should be able to accomplish this by using the statement $ErrorActionPreference = "Stop" at the beginning of your scripts.
$ErrorActionPreference = "Stop"
The default setting of $ErrorActionPreference is Continue, which is why you are seeing your scripts keep going after errors occur.
$ErrorActionPreference
Continue