Powershell Errors out correctly in ISE but doesnt in Command line execution
===

I am running a command in powershell ISE that was exiting out how I expected, but when I moved the code to command line to execute in different environments, I wasnt receiving the error anymore. The error only happens in ISE. I have tried to use -sta on the command line like others posted, but have not had luck.

    $SIEBEL_HOME\srvrmgr.exe /c "Run Command"
    echo "Exit Code: $lastExitCode - Return Code: $?"

When I run that via ISE I get the following output:
    
    Exit Code: 0 - Return Code: False

When I run that command on the command line I get the following output:
    
    E:\powershell.exe -sta -file script.ps1
    
    Exit Code: 0 - Return Code: True

As you can see, I am trying to check the return code and get the correct action in ISE, but do not get the correct result via command line.

I am wondering if there are different environment variables that Windows is using when running in ISE. I notice that when I run it through ISE the console shows the errors in red.