Powershell.exe does not set an exit code when -File is used. - by Neptune443

Status : 

 


29
0
Sign in
to vote
ID 777375 Comments
Status Active Workarounds
Type Bug Repros 9
Opened 1/24/2013 5:26:01 AM
Access Restriction Public

Description

The Powershell.exe does not set an exit code when -File is used.

If we have a .PS1 file called error.ps1 with the following script:

  throw "Help"

and from CMD.exe we execute it with the -command parameter in the following way.

  powershell -command .'d:\error.ps1'

Then the exit code in %errorlevel% is set to 1.
On the other hand, if we execute powershell.exe with the -file parameter in the following way:

  powershell -file 'd:\error.ps1'

Then the exit code in %errorlevel% is set to 0.
Sign in to post a comment.
Posted by Doug Finke on 5/27/2014 at 9:01 AM
Looks like the same result in v5.0 preview
Posted by Eugene Baranov on 3/19/2014 at 11:55 AM
Please fix this.
Posted by mnvm on 2/21/2014 at 7:27 AM
This bug still occurs in PS 4.0.