我在 Powershell ISE(手动加载脚本并按 F5)和 Powershell 控制台(执行脚本文件)中运行完全相同的 script.ps1 文件。它们都可以工作,但 ISE 会显示控制台不显示的错误。为什么?
代码是:
git push origin master
Write-Host "lastExitCode: $lastExitCode Last command was successful: $?"
此代码在 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
这在控制台中:
Everything up-to-date
lastExitCode: 0 Last command was successful: True
您可以看到成功状态也不相同。