Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
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.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista Tutorial - Powershell TRAP for non-terminating errors

Reply
 
Old 03-23-2007   #1 (permalink)
mpriem
Guest


 
 

Powershell TRAP for non-terminating errors

Hi there,

I have some questions about the powershell error handling for non-
terminating errors.
I'm writing a script for Exchange 2007 and want to trap Exchange
specific exceptions like
[Microsoft.Exchange.Management.Tasks.MachineNotClusteredException] and
[Microsoft.Exchange.Configuration.Tasks.ManagementObjectNotFoundException]

The problem is that these are non-terminating errors and I cannot trap
them using the

trap
[Microsoft.Exchange.Configuration.Tasks.ManagementObjectNotFoundException]
{
............................
}
Script blocks.

If I want to trap them I need to add the -ErrorAction Stop to my
cmdlets. This however changes the Exception type to
[System.Management.Automation.ActionPreferenceStopException], which
prevents me from using different trap{} scriptblocks for my error
handling within the same scope.

This is driving me nuts. Is there any way to get the non-terminating
errors trapped ????

Cheers & Thanks,

Mark


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Powershell 2 startup Errors PowerShell
PSH Guru needed ! : Trapping terminating errors PowerShell
Wooly concepts? Terminating and non-terminating errors. PowerShell
How to trap this error in PowerShell PowerShell
Identifying errors in PowerShell - how? PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46