PowerShell script exchange
Post Reply
flo.g
Lurker
Posts: 1
Liked: never
Joined: Apr 27, 2020 1:33 pm
Contact:

Simple PowerShell daily export in .csv

Post by flo.g »

Hi everyone,

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.

    Image



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
veremin
Product Manager
Posts: 20413
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Simple PowerShell daily export in .csv

Post by veremin »

The reporting topic has been discussed several times on these forums, so, please, check previous threads (for instance, this report appears to have everything you want). Thanks!
Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests