
Part IV: Automating Administration
470
The first line of the script adds the Exchange snap - in. If you run a PowerShell script from the command
line you don ’ t get the Exchange management snap - in, so you need to add it manually. The second line of
the script grabs the parameter that is passed to the script on the command line. The
$args special
variable is an array of the arguments that were passed to the script on the command line. The first item
in the array is the first parameter specified on the command line. The following example uses a single
argument in the script to specify the file to open and parse the contents of it so that you can determine
which mailbox stores the script needs to modify:
Add-PSSnapin *Exchange* | out-null
$MBItems = get-content -path $args[0]
You use the Get-Content cmdlet to open the filename that you passed on the command line. Next, for
each line read in from the file, you are going to run a
Set-MailboxDatabase cmdlet to set the defaults
that have been defined for your Exchange users. For a detailed discussion of the
Set-MailboxDatabase
cmdlet please reference Chapter 8 . You will want to construct a
Set-MailboxDatabase command that
sets all relevant settings to meet your standard.
foreach ($objItem in $MBItems)
{
Set-MailboxDatabase $objitem -IssueWarningQuota 300MB -ProhibitSendQuota 400MB -
ProhibitSendReceiveQuota 600MB -ItemRetention ...