This is needed for our Audits - as there is numerous Replication jobs, we don't print them for the daily checklist but during Audit, we need to go through a heap of emails to select and print selected date.
Having a single report for a whole day in .html or .csv/xlsx will be a lot better.
I got this going so far, where I pull a few details from all Replication jobs.
It currently list all jobs, their status, next scheduled run etc but only for the current session/job.
I need it to be able to go back into the history of the days Replication as it replicates 2-4 times a day.
Code: Select all
param(
[String]$outfile="C:\Reports\ReplicaReport.$((Get-Date).ToString('dd-MM-yyyy_HH-mm')).html",
[String]$Server="localhost"
)
if ((Get-PSSnapin -Name VeeamPSSNapin -ErrorAction SilentlyContinue) -eq $null)
{
Add-PSSnapin VeeamPSSNapin
}
$head = @"
<style>
th {background-color: #00aff0}
table {border-collapse: collapse}
table, th, td {
border: 1px solid black;
padding: 5px
}
th {color: white}
body {font-family: sans-serif}
</style>
"@
$results = @()
######
## Connect to server
######
if ($Server -eq $null) {
Connect-VBRServer -Server $server
} else {
Disconnect-VBRServer
Connect-VBRServer -Server $server
}
# Get Replication Jobs
$JobNames = Get-VBRJob | Where-Object {$_.JobType -eq "Replica"}
foreach ($JobName in $JobNames) {
$Job = Get-VBRJob -name $JobName.Name
$LastSession = $Job.FindLastSession()
$Name = $Job.Name
$Status = $LastSession.State
$Progress = "$($LastSession.BaseProgress)%"
$Test = $job.ScheduleOptions.get_NextRun()
$results += New-Object PSObject -Property @{JobName = $Name; Status = $Status; Progress = $Progress; Test = $Test}
}
$results |
Select JobName, Status, Progress, New |
sort @{expression="Status";Descending=$false},@{expression="JobName";Ascending=$true} |
ConvertTo-Html -body "<H2>Veeam Replication Job </H2> <p>The following report was run on $(get-date).</p>" -PreContent $head -Title "Veeam OffSite Backups Information" |
foreach {
$PSItem -replace "<td>Working</td>", "<td style='background-color:green; color: white'>Running</td>" -replace "<td>Idle</td>", "<td style='background-color:orange; color: white'>Idle</td>" -replace "<td>Stopped</td>", "<td style='background-color:red; color: white'>Stopped</td>"
} | Out-File $outfile