Prev | Current Page 638 | Next

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

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

The cmdlet will return an object with the data read in from the file that can be used in a
pipeline or script.
An example that we have used previously in the book can also be used to show how to use
Import-Csv. This time, however, more detail will be given to describe how and why it works. First you
Chapter 16: Reporting, Maintenance, and Administration
467
need to start with a simple CSV file named mailboxes.csv that has the information you need to create
the mailboxes. The file is created in Notepad and looks like the following list:
UPN,Name,Alias
jstidley@exchangeexchange.local,JoelStidley,jstidley
bkeane@exchangeexchange.local,BrendanKeane,bkeane
jcarpenter@exchangeexchange.local,JimCarpenter,jcarpenter
To use this file Import-Csv is used to read in the contents of the file and assign it to a variable. Once the
data is assigned to a variable, access to the data is as simple as working with a dataset. A foreach loop
can be used to step through each of the items in the object. Each column from the spreadsheet will be a
property of the items; this makes working with the values of the properties just like working with any
other object, and very easy.
@newUsers = Import-Csv Mailboxes.csv
foreach ($objItem in $newUsers)
{
}
Passwords are a special case when working in PowerShell.


Pages:
626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650
drukarki fiskalne kraków willa karmazyn międzyzdroje www.books61.hobbitstory.com terapia magnetyczna Informacje o hostingu