Also,
you can do some standard formatting as well. The following code shows modifying the format of the
output value:
$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(MB)??? -value (???{0:n0}??? -f
($dbSize.Length/1024KB))
$returnedObj
}
Notice how the data looks in Figure 16 - 13 . The size is represented in megabytes and with no numbers
after the decimal point.
Figure 16-13
This formatting was done by using the filter {0:n0} when the value is added to $returnObject . This
filter means that the data being entered is a number and should have the (n)umber followed by zero (0)
digits after the decimal. If you wanted to have one number after the decimal you could change this filter
to {0:n1} .
Chapter 16: Reporting, Maintenance, and Administration
483
Simple Monitoring with PowerShell
Nowadays most enterprises have an in - place monitoring solution; however, at times you may need to
create a simple script to monitor a condition that is temporary enough that developing a script for the
monitoring tool would take too much time or effort.
Pages:
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670