gpt4 book ai didi

powershell - Powershell |无法弄清楚陷阱功能

转载 作者:行者123 更新时间:2023-12-02 23:47:43 26 4
gpt4 key购买 nike

好吧,我不知所措>。>我尝试了try / catch和trap函数,但不会捕获此错误...

# Adjustable Variables
$Computers_Path = ".\Compuers.txt"
$Log_Path = ".\Log.txt"

# Script Specific Variables


# Validate Adjustable Variables
TRAP { Write-Host "Unable to locate list of computer names at $Computers_Path"; Continue; }
$Computers = Get-Content $Computers_Path

最佳答案

试试这个:

$Computers = Get-Content $Computers_Path -ea stop

这使 trap捕获异常。

关于powershell - Powershell |无法弄清楚陷阱功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13196857/

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