Look at a simple example of a script that you could
schedule to run every morning to check whether full backups have run on all of the databases in the last
two days.
The first line returns a file of all of the mailbox databases in the organization, however to be able to get
information on the backup status you have to specify the Status switch parameters. That information is
passed to the Select-Object cmdlet to reduce the amount of data passed to the $results ; in this
example the only two values that matter are the identity or the name of the database and
LastFullBackup , which is the time the last full backup completed successfully.
$results = Get-MailboxDatabase -Status | Select-Object Identity, LastFullBackup
Most of this script you have seen in other parts of this book. The new cmdlets introduced here are
Get-Date and New-TimeSpan . The Get-Date cmdlet simply returns the date and time when the cmdlet
is run and has the following command syntax:
Get-Date [[-date] < DateTime > ] [-displayHint { < Date > | < Time > | < DateTime > }] [-
format < string > ] [-year < int > ] [-month < int > ] [-day < int > ] [-hour < int > ] [-minute
< int > ] [-second < int > ] [ < CommonParameters > ]
Get-Date [[-date] < DateTime > ] [-displayHint { < Date > | < Time > | < DateTime > }] [-
uFormat < string > ] [-year < int > ] [-month < int > ] [-day < int > ] [-hour < int > ] [-minute
< int > ] [-second < int > ] [ < CommonParameters > ]
The displayHint parameter can be used to specify what portion you want returned.
Pages:
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671