As you can imagine, once you
really begin to harness the power of PowerShell you are going to have more and more ideas that
you want to try out. In this chapter we discuss using PowerShell to create some reports and to help
automate some administrative tasks. Because the sheer breadth of what you can accomplish with
PowerShell scripting is immense, we are going to pick just a few examples to give you the tools
you need to create your own scripts.
This chapter covers:
??‘ Reading in files for processing
??‘ Advanced output techniques
??‘ Examples for using these techniques
Reading in Files
This section discusses the following cmdlets:
??‘ Import-Csv
??‘ Get-Content
One of the basic functions you will want to perform is to read in a file and work with the data that
you find. You might wish to read in a file with a list of mailboxes that need to be created, or you
might need to update a list of mailboxes with new office information. If you have been using
Part IV: Automating Administration
466
Exchange since version 5.5 you might remember all of the account modifications that could be done by
importing and exporting CSV files. If you long for those days, you can relive them using PowerShell!
The basic command for reading in a file is Get-Content . You can open a file and read it by running
Get-Content and specifying the file you want to read in:
Get-Content [-path] < string[] > [-totalCount < long > ] [-readCount < long > ] [-include
< string[] > ] [-exclude < string[] > ] [-filter < string > ] [-force] [-credential
< PSCredential > ] [-encoding { < Unknown > | < String > | < Unicode > | < Byte > |
< BigEndianUnicode > | < UTF8 > | < UTF7 > | < Ascii > }] [ < CommonParameters > ]
Get-Content [-literalPath] < string[] > [-totalCount < long > ] [-readCount < long > ] [-
include < string[] > ] [-exclude < string[] > ] [-filter < string > ] [-force] [-credential
< PSCredential > ] [-encoding { < Unknown > | < String > | < Unicode > | < Byte > |
< BigEndianUnicode > | < UTF8 > | < UTF7 > | < Ascii > }] [ < CommonParameters > ]
Get-Content requires that a file is provided to read from.
Pages:
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648