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

Understand the Use of Functions

As you start creating your scripts, you will eventually get to the point where you need to break them down into smaller elements that can be called multiple times. Sometimes, it's helpful to break apart scripts just for readability, and sometimes you do it because you need to call the same routine more than once. To do this, you create a function. Think of a function as a compartmentalized script that is called just like a cmdlet.

Create Functions

Functions are very similar to script blocks in that they contain executable code. The main difference between a function and a script block is that script blocks are anonymous, which means they have to be assigned to a variable before they can be executed. Functions, ...

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