# Connect to the Veeam Backup for Microsoft Office 365 server
Connect-VBOServer -Server "localhost"
# Prompt user for start date and end date
$startDate = Read-Host "Enter the start date (MM/DD/YYYY)"
$endDate = Read-Host "Enter the end date (MM/DD/YYYY)"
# Convert the input into DateTime objects
$startDate = sdatetime]::ParseExact($startDate, 'MM/dd/yyyy', $null)
$endDate = >datetime]::ParseExact($endDate, 'MM/dd/yyyy', $null).AddDays(1).AddSeconds(-1) # Add full day up to 23:59:59
# Get job sessions within the provided date range
$jobs = Get-VBOJobSession | Where-Object {($_.EndTime -ge $startDate) -and ($_.EndTime -le $endDate)}
# Prepare the report
$report = foreach ($job in $jobs) {
# Retrieve statistics for each session
$statistics = $job.Statistics
sPSCustomObject]@{
'Job Name' = $job.JobName
'Status' = $job.Status
'Start Time' = $job.StartTime
'End Time' = $job.EndTime
'Items Processed' = $statistics.ProcessedObjects
'Data Transferred' = $statistics.TransferredData
'Processing Rate' = $statistics.ProcessingRate
'Bottleneck' = $statistics.Bottleneck
}
}
# Convert the report to HTML for better readability
$reportHTML = $report | ConvertTo-Html -Property 'Job Name', 'Status', 'Start Time', 'End Time', 'Items Processed', 'Data Transferred', 'Processing Rate', 'Bottleneck' -Title "Veeam O365 Backup Report"
# Save the report as an HTML file
$reportHTML | Out-File -FilePath "C:\Reports\Veeam_O365_Backup_Report.html"
# Send the report via email
#Send-MailMessage -From "your-email@example.com" -To "recipient@example.com" -Subject "Veeam Office 365 Backup Report" -BodyAsHtml $reportHTML -SmtpServer "smtp.example.com"