Prev | Current Page 87 | Next

Joezer Cookey-Gam, Brendan Keane, Jeffrey Rosen, and Jonathan Runyon

"Professional Windows PowerShell for Exchange Server 2007 Service Pack 1"

Use functions to accomplish more complex
tasks without the monotony of entering the same command elements over and over.
Function definition begins with the keyword Function , followed by the name of the function and a
block of code enclosed in curly braces: {} . A function can contain a single or multiple commands, and
the definition can span multiple lines as long as opening brace is entered on the first line and the closing
brace is entered on the last line.
Functions can take as input from the command line one or more arguments entered at the time the
function is run. By providing input values to the function as parameters, you can create flexible
command structures that provide the functionality you need without being limited to static values
embedded in the function itself.
For example, the Get-Mailbox cmdlet by default displays results as Name , Alias , ServerName , and
ProhibitSendQuota values in a table format. These may not be the most interesting values for your
needs, so you would like to have another cmdlet that displays a different set of values by default.
Creating a function that uses the Get-Mailbox cmdlet with customized output formatting is a quick and
easy way to get the results you need. Entering this function at the command line looks like this:
[PS] C:\ > Function get-mailbox2
> > {
> > param($name)
> > Get-Mailbox $name | Format-List Name, Database, OrganizationalUnit
> > }
> >
Chapter 2: Using Exchange Management Shell
51
The results of running this function along with a valid mailbox - enabled account identity as input looks
like this:
[PS] C:\ > get-mailbox2 johdoe
Name : John Doe
Database : MB001\First Storage Group\Mailbox Database
OrganizationalUnit : exchangeexchange.


Pages:
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
Kotły CO regeneracja tonerów Poker Porady pozycjonowanie stron poker online