O'Reilly logo

Automating Microsoft® SharePoint® 2010 Administration with Windows PowerShell® 2.0 by Shannon Bray, Gary Lapointe

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Add Error Handling to Scripts

When you get to the point where you are creating scripts and modules that you wish to reuse or share within your organization or publicly, you will want to put a lot of thought into how you will handle errors.

In some cases, you will want to generate and “throw” an error back to the user, perhaps due to invalid user input or some other condition that requires the caller's attention before continuing. In other cases, you will need to “trap” or “catch” an error and perform some processing to address the error or otherwise append some information to the error and throw it back to the user. And in still some other cases, your error handling will be in the form of basic cleanup of objects to prevent performance degradation. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required