Prev | Current Page 592 | Next

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

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

Therefore it is directed to the Out-Null cmdlet
via pipeline. All default output from New-Mailbox is basically ??? thrown away. ???
# Create the mailbox enabled accounts
foreach ($user in $users)
{
New-Mailbox -Name:$user.name -Database:$user.Database `
-OrganizationalUnit:$user.OrganizationalUnit `
-UserPrincipalName:$user.UserPrincipalName `
-FirstName:$user.FirstName -LastName:$user.LastName `
-Password:$password -ResetPasswordOnNextLogon:$true `
-ErrorVariable err | out-null
After each execution of New-Mailbox , an if statement is used to test if $err is holding a value not equal
to null. If New-Mailbox encountered no errors during execution, the value of $err should still be set to
null. If there was an error during execution, $err holds an error message corresponding to the error that
was encountered. If an error was encountered the conditional test evaluates as true and the code block is
executed.
The $errorString variable is used to store a text message string that includes the name of the user
( $user.name ) that was being processed when the error occurred. The string includes the keyword
[ERROR] to make it easier to search the log file when looking for errors. Note that this is an arbitrary
word and not a specific Windows PowerShell keyword.
Part IV: Automating Administration
440
The Out-File cmdlet is used to append the bulk-newmailbox.


Pages:
580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604
męskie skarpetki rowerowe Apartamenty Świnoujście wczasy odchudzające rekuperatory Powiększanie ust kraków