gpt4 book ai didi

powershell - ErrorAction默认在PowerShell脚本中停止

转载 作者:行者123 更新时间:2023-12-03 00:59:39 25 4
gpt4 key购买 nike

如何在PowerShell脚本中设置所有 Action 的ErrorAction属性设置为Stop?

附注:Powershell 2.0

最佳答案

为脚本设置$ErrorActionPreference以使其停止:

$ErrorActionPreference = "Stop"

编辑:正如 ivan-mirchev所指出的那样,此更改当然不是永久的,仅在执行代码的运行空间中有效。当您打开一个新的Powershell session 时,它将具有默认值 $ErrorAction = 'Continue'

关于powershell - ErrorAction默认在PowerShell脚本中停止,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58284122/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com