Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is Powershell ISE showing errors that Powershell console does not show?

I'm running exactly the same script.ps1 file in a Powershell ISE (manually loading the script and pressing F5) and in a Powershell console (executing the script file). They both work but ISE shows errors that the console does not. Why?

The code is:

git push origin master
Write-Host "lastExitCode: $lastExitCode Last command was successful: $?"

This code output this error in the ISE:

git.cmd : Initializing to normal mode
At E:\script.ps1:28 char:4
+ git <<<<  push origin master
    + CategoryInfo          : NotSpecified: (Initializing to normal mode:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

Initializing to normal mode

Everything up-to-date

lastExitCode: 0 Last command was successful: False

And this in the console:

Everything up-to-date
lastExitCode: 0 Last command was successful: True

You can see that the success status is not the same also.

like image 262
Malartre Avatar asked Jun 01 '12 19:06

Malartre


People also ask

Is PowerShell and PowerShell ISE the same?

The principal difference between the two is convenience. PowerShell is a simpler and more straightforward scripting and execution environment, while the ISE provides more flexible and forgiving editing and execution features.

What happened to PowerShell ISE?

The PowerShell ISE is no longer in active feature development. As a shipping component of Windows, it continues to be officially supported for security and high-priority servicing fixes. We currently have no plans to remove the ISE from Windows. There is no support for the ISE in PowerShell v6 and beyond.

What can I use instead of PowerShell ISE?

Most administrators use the PowerShell ISE (Integrated Scripting Environment) to build their PowerShell scripts. But by now Microsoft has almost stopped developing PowerShell ISE and recommends using a more powerful, convenient, flexible and free tool instead — Visual Studio Code (VS Code).


2 Answers

as shown in this Stackoverflow answer to prevent git push to print to STDERR the solution is to call the command witn --porcelain option.

then, calling

git push origin master --porcelain

output goes all to STDOUT

like image 181
Stefano Spinucci Avatar answered Jan 04 '23 09:01

Stefano Spinucci


So, the example below case have any error , this command -q 2>&1 | %{ "$_" }` will nullifying the result of errors.

A solution and use: git push -q 2>&1 | %{ "$_" }

like image 21
Juliano Sales Avatar answered Jan 04 '23 09:01

Juliano Sales