local/Users
The definition of the function in this example starts with the Function keyword, followed by a unique
name, in this case Get-Mailbox2 . Be careful when choosing a name because Windows PowerShell does
no validation to prevent you from entering the name of an existing cmdlet. Names can contain any
alphanumeric character, but must always start with a letter.
When you press Enter at the end of the first line, Windows PowerShell expects more instructions are to
be entered and drops to the next input line. The two greater than characters ( > > ) on the input line
prompt the user that Windows PowerShell is expecting more input. The script block then starts with
entering the left curly brace ( { ).
The input parameter definition is very simple, using the keyword param followed by a variable name
enclosed in parentheses, in this case $name . This parameter will be used for inputting the identity of the
mailbox - enabled account for which the function gets information. Multiple parameter variable names
can be defined, separated by commas. The use of input parameters is optional, but their use extends the
usefulness of a function by allowing you to enter dynamic information at the time the function is run.
The next line comprises the main command for this function. This command uses Get-Mailbox to get
information about the mailbox - enabled account identified by the $name parameter, then passes that
object to the Format-List cmdlet to output its Name , Database , and OrganizationalUnit properties
in list format.
Pages:
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100