Home Dashboard Directory Help
Search

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


Status: 

Active


19
0
Sign in
to vote
Type: Bug
ID: 777375
Opened: 1/24/2013 5:26:01 AM
Access Restriction: Public
0
Workaround(s)
view
8
User(s) can reproduce this bug

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.
Details
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.
Sign in to post a workaround.