Prev | Current Page 657 | Next

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

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

How can you do this when the identity and the file length are the results of two separate
commands that are run? You can create a PowerShell object named $returnedObject using the
New-Object cmdlet for each mailbox store and then you can display the results together. When using
the Add-Member cmdlet to add values to the PowerShell object you need to define the type, name, and
value of the property. In the following example you can see two NoteProperties added to the object,
one named Server\StorageGroup\Database and the other named Size(KB) , each with a value
assigned to it from the respective command:
$server = [System.Environment]::MachineName
$db = get-MailboxDatabase -server $server
foreach ($objItem in $db)
{
$dbsize = get-childitem $objItem.EdbFilePath
$returnedObj = new-object PSObject
$returnedObj | add-member NoteProperty -name ???Server\StorageGroup\Database??? -
value $objItem.Identity
$returnedObj | add-member NoteProperty -name ???Size(KB)??? -value $dbSize.Length
$returnedObj
}
The output, shown in Figure 16 - 12 , is in a nice table format that you can easily read or output to a file for
reference.
Figure 16-12
Part IV: Automating Administration
482
What can you do about formatting the file size so that it is shown in a more ??? user - friendly ??? number
format? You can divide the length by 1024 kilobytes so that the size is represented in megabytes.


Pages:
645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669
Kenny Loggins Milk Inc. Monty Python for your soul kreskowka