http://www.sqlservercentral.com/blogs/chadmiller/2009/06/25/powershell-_2B00_-smo-error-handling-tips/

Printed 2014/07/31 10:11AM

Powershell + SMO Error Handling Tips

By Chad Miller, 2009/06/25

Allen White posted a helpful post on SMO error handling with Powershell. Actually the same concept equally applies to SMO coded in any other .NET language. SMO uses an error object's InnerException which can be several layers deep and you must traverse the nested InnerExceptions to get to the detailed error message. Related to Allen's post, Michiel Worries gives us another useful technique to get back full error messages. If you find your Powershell scripts are throwing too generic of a error message, you may find some useful messages in InnerException.
 
Links:
MSDN: Handling SMO Exceptions
Allen White: Handling Errors in PowerShell
PowerShell Tips & Tricks: Getting more detailed error information from PowerShell
 
 
 

Copyright © 2002-2014 Simple Talk Publishing. All Rights Reserved. Privacy Policy. Terms of Use. Report Abuse.