powershell - Cmdlet.EndProcessing和Cmdlet.StopProcessing之间的区别

标签 powershell cmdlets

编写Powershell cmdlet时,EndProcessingStopProcessing有什么区别?它们听起来相同,描述几乎相同,并且后者未出现在cmdlet lifecycle documentation中。

最佳答案

如果取消了CmdLet的执行,则调用StopProcessing(按CNTRL-C将导致执行StopProcessing)。

如果CmdLet的执行正常结束,则调用EndProcessing。

我通常使用StopProcessing和EndProcessing来做同一件事……就是清除在BeginProcessing或ProcessRecord期间提供的资源,尽管在某些情况下,每个 Action 提供的内容有所不同。

生命周期文档中未显示它似乎是一个错误。

关于powershell - Cmdlet.EndProcessing和Cmdlet.StopProcessing之间的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1628127/

相关文章:

powershell - 捕获 PowerShell 工作流程中的错误

sql - foreach 和 do while 用于构建插入查询

PowerShell - 获取被调用应用程序的进程ID

powershell - 在Powershell中串联多个cmdlet

powershell - Azure 资源模板中的 dataDisk.image 参数

powershell - Azure 自动化作业共享订阅上下文

powershell - 对于PowerShell cmdlet,是否可以始终将脚本 block 传递给字符串参数?

Powershell 字符串长度验证

powershell - 您最喜欢的 Powershell Cmdlet 是什么?

c# - 使用SwitchParameter的PowerShell自定义Cmdlet