Skip to content

Instantly share code, notes, and snippets.

@Jaykul
Last active August 29, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Jaykul/bd8a6bbc13aef1b2f2a3 to your computer and use it in GitHub Desktop.
Save Jaykul/bd8a6bbc13aef1b2f2a3 to your computer and use it in GitHub Desktop.
Exceptions and Errors
&{
[CmdletBinding()]param()
&{[CmdletBinding()]param() Write-Error "Demo Error 1" } -EA 0 -EV e;
$PSCmdlet.WriteError($e[0]);
1/0
&{[CmdletBinding()]param() Write-Error "Demo Error 2" } -EA 0 -EV e;
$PSCmdlet.ThrowTerminatingError($e[0])
}
$e = $Error[0..2]
$e | % { $_.Exception } | fl * -force
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment