When a database completes an online
defragmentation pass either an event with an event id of 701 or 703 with a source of ESE is written to the
event log. As you can see from Figure 16 - 1 the event provides information about the online
defragmentation including the number of times it has completed. This level of detail in the event log is
new to Exchange Server 2007 Service Pack 1.
Part IV: Automating Administration
472
Figure 16-1
To find this event for each database you need to filter out all non - essential events. To do this you can use
Get-EventLog and specify that you want to look only at the Application Log. You then need to look at
only the events that have an event ID of 701 or 703 and have a source of ESE.
$EventLogs = get-EventLog -LogName Application | where-object {$_.EventID -eq 703 -
or $_.EventID -eq 701 -and $_.Source -eq ???ESE??™ }
As you can see in Figure 16 - 2 this returns a list of all the events in the event log with this critera. This is
still too much data to be useful. Because you are interested in whether all databases have been
completing the online defragmentation you need to pass in the database variable that you got earlier.
Chapter 16: Reporting, Maintenance, and Administration
473
Because the database name does not have to be be unique on a single server you need to look for the
database path that is listed in the event.
Pages:
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660