Windows PowerShell Exit Codes
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
Windows PowerShell Exit Codes的更多相关文章
- Windows PowerShell:管理服务器
一.概述 Cmdlets 用于服务器的管理方面主要体现在4个方面:服务.日志.进程.服务器管理器. 1.服务 • Get-Service.查看某个服务的属性. • New-Service.创建一个 ...
- Windows PowerShell 入門(10)-デバッグ編
対象読者 Windows PowerShellでコマンドレット操作ができる方 何らかのプログラミング経験があればなお良い 必要環境 Windows PowerShell デバッグメッセージの出力 Po ...
- Windows PowerShell 入門(1)-基本操作編
Microsoftが提供している新しいシェル.Windows Power Shellの基本操作方法を学びます.インストール.起動終了方法.コマンドレット.命名規則.エイリアス.操作方法の調べ方について ...
- [Windows Powershell]-学习笔记(5)
Powershell自动化变量 Powershell 自动化变量 是那些一旦打开Powershell就会自动加载的变量,或者说是运行是变量. 这些变量一般存放的内容包括 用户信息:例如用户的根目录$h ...
- (2)Windows PowerShell使用
什么是PowerShell: Windows PowerShell 是一种命令行外壳程序和脚本环境,使命令行用户和脚本编写者可以利用 .NET Framework 的强大功能.PowerShell是命 ...
- 解决VS2015启动时Package manager console崩溃的问题 - Windows PowerShell updated your execution policy successfully, but the setting is overridden by a policy defined at a more specific scope
安装VS2015,启动以后,Package manager console崩溃,错误信息如下: Windows PowerShell updated your execution policy suc ...
- 用Windows PowerShell 控制管理 Microsoft Office 365
如果想要通过PowerShell控制管理Office365,首先要安装Microsoft Online Services Sign-In Assistant 7.0,链接如下 Microsoft On ...
- 【SharePoint学习笔记】第2章 SharePoint Windows PowerShell 指南
快速了解Windows PowerShell 从SharePoint 2010开始支持PowerShell,仍支持stsadm.exe工具: 可以调用.NET对象.COM对象.exe文 ...
- Office 365 - SharePoint 2013 Online 中使用Windows PowerShell
1.如果想要在SharePoint Online中使用Windows PowerShell,首先需要安装SharePoint Online Management Shell(下载地址附后),如下图: ...
随机推荐
- java基础——Map集合
Map以键值对的形式存储数据,其中Map.entry,是Map的内部类,它用来描述Map中的键值对.Map是一个接口,HashMap是他的一个实现类 Map中有几个重要的方法: get(Object ...
- IDEA项目显示树形结构
- linux简单常用命令
除了yum命令,还有些简单的命令,在此记录一下,加深记忆: free -h 查询内存和交换分区. rpm -qa | grep libaio 查看当前环境是否安装某rpm软件包
- 【dp】P1077 摆花
基础DP题 题目描述 小明的花店新开张,为了吸引顾客,他想在花店的门口摆上一排花,共m盆.通过调查顾客的喜好,小明列出了顾客最喜欢的n种花,从1到n标号.为了在门口展出更多种花,规定第i种花不能超过a ...
- [BZOJ] 1563: [NOI2009]诗人小G
1D/1D的方程,代价函数是一个p次函数,典型的决策单调性 用单调队列(其实算单调栈)维护决策点,优化转移 复杂度\(O(nlogn)\) #include<iostream> #incl ...
- matplotlib绘图(一)
绘制这折现图 导入响应的包 import numpy as npimport pandas as pdfrom pandas import Series,DataFrame%matplotlib in ...
- 05tar命令详解
tar 命令用于对文件进行打包压缩或解压,格式为"tar [选项][文件]". 在Linux 系统中,常见的文件格式比较多,其中主要使用的是 .tar 或者 .tar.gz 或 ...
- python入门:while 循环的基本用法
#!/usr/bin/env python # -*- coding:utf-8 -*- #while 循环的作用 import time while True: ") time.sleep ...
- phpExcel使用方法二
require_once './phpexcel/PHPExcel.php'; // 首先创建一个新的对象 PHPExcel object $objPHPExcel = new PHPExcel(); ...
- matplotlib 设置图形大小时 figsize 与 dpi 的关系
matplotlib 中设置图形大小的语句如下: fig = plt.figure(figsize=(a, b), dpi=dpi) 其中: figsize 设置图形的大小,a 为图形的宽, b 为图 ...