http://www.sqlservercentral.com/blogs/chadmiller/2009/06/25/powershell-_2B00_-smo-error-handling-tips/ Printed 2016/10/23 11:27PM
Powershell + SMO Error Handling Tips
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.