The totalCount parameter specifies the
number of lines that are retrieved. To retrieve the contents of the file with the list of databases in it the
syntax would look like the following:
Get-Content C:\data\Databases.txt
Now that the data has been read in you can loop through each of the lines in the file by using a foreach
loop, which would look like the following:
$dbs = Get-Content C:\data\Databases.txt
foreach ($line in $dbs)
{
}
Sure, this is okay for simple files but what if you need to import a spreadsheet that has multiple columns
of data? This is a very common scenario because when you create mailboxes you need at a minimum the
User Principal Name (UPN), name, and alias of the user. It would be a hassle to read in three different
text files and then try to keep the data together. Thankfully, there is a way to do this with the Import-Csv
cmdlet. A comma - separated value (CSV) file is a text - based file with the data separated into columns with
commas and can be created with Notepad or Microsoft Office Excel. When you create the CSV file that
you want to read in, be sure that the first line in the CSV has the name of the columns, because this makes
the information easier to reference. Import-Csv has the following syntax:
Import-Csv [-path] < string[] > [ < CommonParameters > ]
This is a relatively simple command only requiring a path specified to the CSV file that will be
imported.
Pages:
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649