Creating and running scripts

You can accomplish many tasks by executing individual cmdlets or running multiple commands in a pipeline, but there may be times where you want to create a script that performs a series of operations or that loads a library of functions and predefined variables and aliases into the shell. In this recipe, we'll take a look at how you can create and run scripts in the shell.

How to do it...

  1. Let's start off by creating a basic script that automates a multi-step process. We'll start up a text editor, such as Notepad, and enter the following code:
    param( $name, $maxsendsize, $maxreceivesize, $city, $state, $title, $department ) Set-Mailbox -Identity $name ` -MaxSendSize $maxsendsize ` -MaxReceiveSize $maxreceivesize Set-User ...

Get Microsoft Exchange 2010 PowerShell Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.