For example, $user.name is the name
Part IV: Automating Administration
428
property value for the current object, $user.database is the database property value, and so on.
The property names are determined by the header values used in the CSV file.
The Password property value is provided by the $password variable created earlier in the script. The
script uses the minimum parameters required by New-Mailbox to successfully create a mailbox - enabled
user account, plus the ResetPasswordOnNextLogon parameter to force the new users to set their own
passwords the first time they log in to the domain. This is a good administrative practice.
# Create the mailbox enabled accounts
foreach ($user in $users)
{
New-Mailbox -Name:$user.name -Database:$user.Database `
-OrganizationalUnit:$user.OrganizationalUnit `
-UserPrincipalName:$user.UserPrincipalName -Password:$password `
-ResetPasswordOnNextLogon:$true
}
Note the use of the grave accent character ( ` ) at the end of each line following the New-Mailbox cmdlet.
When this escape character is used at the end of a command line with no other character immediately
following, it instructs Windows PowerShell to continue reading the command line from the beginning of
the next line. This is a simple way to wrap long commands so they are more readable.
Pages:
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583