Skip to content

Instantly share code, notes, and snippets.

@gregjhogan
gregjhogan / catch-all-command-errors-in-powershell.ps1
Created August 1, 2016 17:39
Catch all errors from commands (including native) run in a powershell script
$ErrorActionPreference = 'Stop'
try
{
npm install bogus-package 2>&1
}
catch
{
Write-Host "Error: $_"
}