Search

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

Active

4
0
Sign in
to vote
Type: Bug
ID: 777375
Opened: 1/24/2013 5:26:01 AM
Access Restriction: Public
0
Workaround(s)
0
User(s) can reproduce this bug
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 (expand)
How often does this happen?
Always Happens

Have you seen this problem before in this product?

Yes, this happens in previous released versions
Reproduction Steps
See above.
Expected Results
%errorlevel% set to 1
File Attachments
0 attachments
Sign in to post a comment.
Sign in to post a workaround.