local -alias mstest1 -
database ???First Storage Group\Mailbox Database??? -Name Mstest1Exch -
OrganizationalUnit Users -password $Password -FirstName Mstest1 -LastName Exch -
DisplayName ???Mstest1 Exch??? -ResetPasswordOnNextLogon $true
The previous example creates a user MSTest1 Exch in Active Directory and a mailbox for that user. The
mailbox is located on the First Storage Group, in mailbox database. The password must be reset at the
next logon. Also the Organizational Unit where this user will be created has been specified.
To set the initial value of the password, you can create a variable called $password that prompts you to
enter an initial password and assigns that password to the variable as a SecureString object:
$Password = Read-Host ???Please Enter your password:??? -AsSecureString
The Read-Host cmdlet reads a line of input from the console. It can be used to prompt for input from a
user or to create secure strings. Hence it takes the prompt or AsSecureString switch parameters. In
the previous example, Read-Host presents Please Enter your password : as a prompt and then each
keystroke will be displayed as an asterisk (*). Upon completion the password is stored as a secure string
in the variable $Password . See Figure 4 - 21 .
Figure 4-21
If the password parameter is not specified during the creation of the user mailbox, Exchange
Management Shell prompts for the password before the user is created.
Pages:
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207