![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | how to work error interception hi, i have a script which control space disk on my servers(more 200). to do it i use wmi object. on some machine, my wmi is out and i have an error message "get-wmiobject : access is denied ..." how can i intercept that ? thanks for all ! |
My System Specs![]() |
| | #2 (permalink) |
| | RE: how to work error interception Get-WmiObject exceptions are usually non-terminating, you cannot trap non-terminating exceptions. You can stop execution when a non-terminating exception is raised by setting Get-WmiObject's parameter -ErrorAction (or -ea) to 'Stop' (or 1), then a Trap statement will trap the [Management.Automation.ActionPreferenceStopException] exception. The non-terminating error is available in your trap as the second element of the $error collection, i.e. $error[1]. trap [Management.Automation.ActionPreferenceStopException] { # handle the exception continue # exit the trap } gwmi ... -ea 1 -- Kiron |
My System Specs![]() |
| | #3 (permalink) |
| | RE: how to work error interception Correction: "The non-terminating error is available in your trap as the second element of the $error collection, i.e. $error[1]." The non-terminating error is wrapped by the ActionPreferenceStopException, which is available in the trap through the current pipeline object '$_'. At least the non-terminating exception's message is appended to ActionPreferenceStopException's message. This stuff is not documented, sorry about 'my non-terminating' error, I was thinking 'theoretically'. ![]() -- Kiron |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| spooler error gone - now can't get printer to work | Vista print fax & scan | |||
| Error Trapping : doesn't work | PowerShell | |||
| Error message. Do the instructions for OE work for this? | Vista mail | |||
| HELP PLEASE I keep getting error 732 with VPN for work | Vista General | |||