I'm not a expert in PowerShell, but I'm trying to make a simple daily report with :
Job name
Status
Start time
End time
Duration
I've 2 types of backup : VMware Backup and Windows Agent Backup with 15 jobs.
- I need help for the Windows Agent Backup, with the script he does not find the jobs.
- I would like a summary, not a full list for each jobs.
Thank you
Code: Select all
Add-PSSnapIn VeeamPSSnapin
$now = Get-Date -Format dd-MM-yyyy_HH-mm
$results_array = @()
$jobs = Get-VBRJob | Where-Object {$_.IsBackup}
ForEach ($job in $jobs) {
$lastsession = $job.FindLastSession()
foreach ($tasksession in $lastsession.GetTaskSessions()) {
$objResult = [pscustomobject][ordered]@{
Job = $job.Name
Status = $job.GetLastResult()
Start_time = $lastsession.CreationTime
End_time = $lastsession.EndTime
Duration = [System.TimeSpan]::Parse($lastsession.EndTime - $lastsession.CreationTime)
}
$results_array += $objResult
}
}
#Export to CSV file
$CSVreportfilename = "C:\temp\Veeam-daily-Report-" + $now + ".csv"
$results_array | Sort-Object Server, JobName, VmName | Export-CSV $CSVreportfilename -NoTypeInformation