PowerShell: throw error

By Xah Lee. Date: . Last updated: .

throw

the keyword throw exit the program and print an error.

$x = 3
if (7 -ne $x) { throw "you got a problem" }

Write-Error

the cmdlet write-error print an error but continue running the program.

$x = 3
if (7 -ne $x) { Write-Error "you got a problem"}