Printed 2017/08/16 03:54PM

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.
MSDN: Handling SMO Exceptions
Allen White: Handling Errors in PowerShell
PowerShell Tips & Tricks: Getting more detailed error information from PowerShell

Copyright © 2002-2017 Redgate. All Rights Reserved. Privacy Policy. Terms of Use. Report Abuse.