Skip to content

Latest commit

 

History

History

Exit-code-0-with-File-script-error

Exit code 0 with File script error

Fixed in PowerShell v5

If a script has a syntax error or throws an error then PowerShell exit code is

  • 0 (success) when a script is specified by the parameter File
  • 1 (failure) when a script is specified by the parameter Command

Consider to use Command when an exit code is essential. Note that Command has its own issues. It is difficult to compose if a script path or arguments contain special characters. Syntax errors in a command cause the exit code 0, see Exit-code-0-with-Command-syntax-error. Also, Command may not return the actual exit code of a script, see Exit-code-5-with-File-1-with-Command.

Scripts


  • Microsoft Connect 750653