Code: Select all
Add-PSSnapin VeeamPSSnapin;
Import-Module Veeam.Archiver.PowerShell;
Import-Module Veeam.Exchange.PowerShell;
Import-Module Veeam.Sharepoint.PowerShell;
Import-Module Veeam.Oracle.PowerShell;
Import-Module Veeam.SQL.PowerShell;
$RestorePoints = Get-VBRApplicationRestorePoint -Exchange;
$ExchangeServers = $RestorePoints | SELECT -Unique -ExpandProperty Name;
# Build Collection of Newest Restore Points Per Server
$RestorePointsNewest = @();
ForEach ($ExchangeServer in $ExchangeServers) {
$RestorePointsSubset = $RestorePoints | WHERE {$_.Name -ieq $ExchangeServer} | SORT -Property CreationTime | SELECT -First 1;
$RestorePointsNewest += $RestorePointsSubset;
$RestorePointsSubset = $Null;
}
ForEach ($RestorePoint in $RestorePointsNewest) {
Try {
# NOTE: This may take several minutes
$Session = Start-VBRExchangeItemRestoreSession -RestorePoint $RestorePoint;
$ExchangeDatabases = Get-VEXDatabase -Session $Session;
ForEach ($ExchangeDatabase in $ExchangeDatabases) {
$Mailboxes = Get-VEXMailbox -Database $ExchangeDatabase;
ForEach ($Mailbox in $Mailboxes) {
$ReportObject = "" | SELECT -Property 'RestorePointTime','ExchangeServer','ExchangeDatabase','MailboxName','MailboxEmail';
$ReportObject.RestorePointTime = $RestorePoint.CreationTime; # Example: "6/11/2019 7:01:26 AM"
$ReportObject.ExchangeServer = $RestorePoint.Name; # Example: "ExchangeServer01"
$ReportObject.ExchangeDatabase = $ExchangeDatabase.Name; # Example: "DAG1DB13.edb"
$ReportObject.MailboxName = $Mailbox.Name; # Example: "Smith Joe"
$ReportObject.MailboxEmail = $Mailbox.Email; # Example: "" <-- Always empty
$ReportCollection += $ReportObject;
}
}
}
Catch {
Write-Host $Error;
}
Finally {
# NOTE: This may take several minutes
Stop-VBRExchangeItemRestoreSession -Session $Session;
}
}