Prev | Current Page 639 | Next

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

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

Passwords are stored as a special secured
string value in memory. This means that this string is not stored in plain text and thus requires special
handling. To streamline this process you can prompt for the user to add the password that will be used
for all of the accounts:
$password = Read-Host ???Enter password??? -AsSecureString
@newUsers = Import-CSV Mailboxes.csv
foreach ($objItem in $newUsers)
{
New-Mailbox -alias $objItem.Alias -name $objItem.Name -UserPrincipalName
$objItem.UPN -Database ???MB001\SG03\MB01??? -OrganizationalUnit Users -Password
$Password -ResetPasswordOnNextLogon:$true
}
You pass the data from the file, specifying the appropriate values from the CSV in the spaces in the
New-Mailbox cmdlet. Using the foreach loop you are stepping through the values that have been read
in from the CSV file, line by line. To obtain the value for the current item, all you need to do is look at the
property of the current item that is assigned to the $objItem variable.
You could take this example a step further by adding in more columns in this spreadsheet so that you
can assign the street address or maybe even the group membership of the new accounts.
Part IV: Automating Administration
468
Exporting Data
This section discusses the following cmdlets:
??‘ Out-File
??‘ Export-Csv
No doubt, it is a requirement to be able to save data for reference at a later time.


Pages:
627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651
Christina Milian Lizar Losza Vera Ennio Morricone obroncyaskalonu