I\'ve been looking for a way to terminate a PowerShell (PS1) script when an unrecoverable error occurs within a function. For example:
function foo() { #
Exit will exit PowerShell too. If you wish to "break" out of just the current function or script - use Break :)
Exit
Break
If ($Breakout -eq $true) { Write-Host "Break Out!" Break } ElseIf ($Breakout -eq $false) { Write-Host "No Breakout for you!" } Else { Write-Host "Breakout wasn't defined..." }