随笔 - 24, 文章 - 0, 评论 - 1, 引用 - 0
数据加载中……

Powershell Tips:捕获错误

 

trap {
  
write-host "Error connecting to $computer" -fore red "$computer" | out-file c:\demo\errors.txt -append 
  continue
}

$computer 
= "localhost"
get-wmiobject win32_operatingsystem -comp $computer -ErrorAction stop

$computer 
= "server2"
get-wmiobject win32_operatingsystem  -comp $computer -ErrorAction stop

$computer 
= "localhost"
get-wmiobject win32_operatingsystem  -comp $computer -ErrorAction stop

posted on 2009-04-15 13:56 nicktang 阅读(223) 评论(0)  编辑 收藏 引用 所属分类: Powershell

只有注册用户登录后才能发表评论。