Windows PowerShell Exit Codes
2016-01-06 13:41
423 查看
Windows PowerShell Exit Codes
PSMDTAG:FAQ: How can my script control the PowerShell exit code?Answers:
A normal termination will set the exitcode to 0
An uncaught THROW will set the exitcode to 1
The EXIT statement will stop the process and set the exitcode to whatever is specified.
c:\>powershell -noprofile -command "Write-output Test"
Test
c:\>echo %errorlevel%
0
c:\>powershell -noprofile -command "Write-output Test; throw 'ERROR'"
Test
ERROR
At line:1 char:25
+ Write-output Test; throw <<<< 'ERROR'
c:\>echo %errorlevel%
1
c:\>powershell -noprofile -command "Write-output Test; exit 31492"
Test
c:\>echo %errorlevel%
31492
Jeffrey Snover [MSFT]
Windows PowerShell/MMC Architect
Visit the Windows PowerShell Team blog at: http://blogs.msdn.com/PowerShell
Visit the Windows PowerShell ScriptCenter at
http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx
相关文章推荐
- shell 特殊字符用例
- Linux shell命令 cp 加上-f还是提示是否覆盖
- Enable and Use Remote Commands in Windows PowerShell
- power shell remoting
- linux shell基础
- 195. Tenth Line leetcode bash
- 194. Transpose File leetcode Bash
- 193. Valid Phone Numbers leetcode Bash
- 192. Word Frequency My Submissions Question Leetcode Bash
- -bash: ulimit: pipe size: cannot modify limit: Invalid argument
- -bash: ulimit: pipe size: cannot modify limit: Invalid argument
- -bash: ulimit: pipe size: cannot modify limit: Invalid argument
- shell\comdlg32\fileopensave.cpp(9456)\COMDLG32.dll!
- chapte13:学习shell scripts之(3)条件判断式
- shell处理文件
- shell 中常见问题处理记录
- “HINSTANCE ShellExecuteW(HWND,LPCWSTR,LPCWSTR,LPCWSTR,LPCWSTR,INT)”
- 使用Jailkit在CentOS上建立一个受限shell
- 《Linux程序设计》笔记(二)shell程序设计
- Shell的系统变量