首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Powershell |找不到Trap函数

Powershell |找不到Trap函数
EN

Stack Overflow用户
提问于 2012-11-02 22:08:37
回答 1查看 140关注 0票数 2

好吧,我很困惑,我已经尝试了try/catch >.> trap函数,但是它不能捕捉到这个错误…

代码语言:javascript
复制
# 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
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-11-02 22:24:33

试试这个:

代码语言:javascript
复制
$Computers = Get-Content $Computers_Path -ea stop

这会让trap捕捉到异常。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13196857

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档