Updated Veeam Weekly Backup Report – Powershell (BAW6)

Back in 2015, I created a 3-day Backup Report for Veeam that was based on the ‘SysAdmin Modular Report’ (SAMReport) – this is the link to the original post for that report:  http://virtualworlduk.co.uk/3-day-veeam-backup-report-powercli/

That report has been useful for a couple of years but I felt that I could do better, without having to link back to the vCenter server quite so much.  After looking around at what other people were doing, I stumbled across the work that Shawn Masterson has been doing with his ‘Veeam v9 – My Veeam Report v9.5.3’ (https://blog.smasterson.com/2017/12/22/veeam-v9-my-veeam-report-9-5-3/) and I was then able to utilise some of his great work to create an updated version of my report as a full Weekly Backup Report.  The comparison between my old report and my new report are shown below:

Old Report

 

Updated Report

As you can see from the screenshot, the look of the new report is more modern.  This screenshot is taken from my lab environment with some forced failures.  Backup failures are highlighted Red, VMs that end with a Warning status are highlighted Yellow and if a virtual machine has not been backed up at all (or is new), then you’ll see a blank next to the name on the days that it hasn’t been backed up.  This means that it should be easier to identify if there are any issues.

Other key items to be aware of with this, is that I am utilising Veeam 9.5 to run the report against, the report still needs to be run on the Veeam server itself but should run significantly quicker than previous reports, as it is just referencing the information in Veeam rather than connecting to vCenter.  For my lab environment, I back up the virtual machines by datastore rather than adding individual backups to a job, this means that all of my virtual machines are automatically added to the backup jobs once a new virtual machine is created.  It also means that my report should always include all of the virtual machines in the report.  I am utilising Powershell version 5 on one of my systems but have also tested this utilising Powershell version 4.

The code may still not be optimised as best as it could be and the report may be a bit rough and ready but it seems to work okay for me.

The code listing is below:


If (!(Get-PSSnapin -Name VeeamPSSnapIn -ErrorAction SilentlyContinue)) {
If (!(Add-PSSnapin -PassThru VeeamPSSnapIn)) {
Write-Error "Unable to load Veeam snapin" -ForegroundColor Red
Exit
}
}

get-module -ListAvailable VM* | Import-Module

$datetoday = [DateTime]::Today.ToString("ddd d MMM yyy")
$ReportDate = get-date -f yyyy-MM-dd

$veeamExePath = "D:\Program Files\Veeam\Backup and Replication\Console\Veeam.Backup.Shell.exe" # this should be the location of the Veeam.Backup.Shell.exe file
$veeamExe = Get-Item $veeamExePath

$VeeamVersion = $veeamExe.VersionInfo.ProductVersion

$emailTo = "Change This" # Email address that you wish to send the report to

$smtpServerref = "Change This" # SMTP server name used for emailing

$emailFrom = "Change This" # Email address that the report should come from

$Outputlocation = "Change This" # this should be the directory and file name to save a copy of the report

# HTML Stuff - this sets up the HTML report sections
$headerObj = @"
<!DOCTYPE html>
<html>
<head>
<title>"Veeam Backup Report - $datetoday</title>
<style>
body {font-family: Tahoma; background-color:#ffffff;}
table {font-family: Tahoma;width: $($rptWidth)%;font-size: 12px;border-collapse:collapse;}
<!-- table tr:nth-child(odd) td {background: #e2e2e2;} -->
th {background-color: #e2e2e2;border: 1px solid #a7a9ac;border-bottom: none;}
td {background-color: #ffffff;border: 1px solid #a7a9ac;padding: 2px 3px 2px 3px;}
</style>
</head>
"@

$bodyTop = @"
<body>
<center>

<table>
<tr>
<td style="width: 100%;height: 12px;border: none;background-color: #143d63;color: White;font-size: 12px;vertical-align: bottom;text-align: right;padding: 0px 5px 0px 0px;"Report generated on $(Get-Date -format g)</td>
</tr>
<tr>
<td style="width: 100%;height: 24px;border: none;background-color: #ffffff;color: Black;font-size: 24px;vertical-align: bottom;text-align: center;padding: 0px 0px 0px 15px;">Veeam Backup Report - $datetoday</td>

</tr>
<tr>
<td style="width: 100%;height: 12px;border: none;background-color: #143d63;color: White;font-size: 12px;vertical-align: bottom;text-align: right;padding: 0px 5px 0px 0px;">Veeam Backup & Replication v$VeeamVersion</td>
</tr>
<tr>
<td style="width: 50%;height: 12px;border: none;background-color: ZZhdbgZZ;color: White;font-size: 12px;vertical-align: bottom;text-align: left;padding: 0px 0px 2px 5px;">$rptMode</td>
<td style="width: 50%;height: 12px;border: none;background-color: ZZhdbgZZ;color: White;font-size: 12px;vertical-align: bottom;text-align: right;padding: 0px 5px 2px 0px;">MVR v$MVRversion</td>
</tr>
</table>
"@

$subHead01 = @"
<table>
<tr>
<td style="height: 35px;background-color: #f3f4f4;color: #626365;font-size: 16px;padding: 5px 0 0 15px;border-top: 5px solid white;border-bottom: none;">
"@

$subHead01suc = @"
<table>
<tr>
<td style="height: 35px;background-color: #00b050;color: #ffffff;font-size: 16px;padding: 5px 0 0 15px;border-top: 5px solid white;border-bottom: none;">
"@

$subHead01war = @"
<table>
<tr>
<td style="height: 35px;background-color: #ffd96c;color: #ffffff;font-size: 16px;padding: 5px 0 0 15px;border-top: 5px solid white;border-bottom: none;">
"@

$subHead01err = @"
<table>
<tr>
<td style="height: 35px;background-color: #FB9895;color: #ffffff;font-size: 16px;padding: 5px 0 0 15px;border-top: 5px solid white;border-bottom: none;">
"@

$subHead02 = @"
</td>
</tr>
</table>
"@

$HTMLbreak = @"
<table>
<tr>
<td style="height: 10px;background-color: #626365;padding: 5px 0 0 15px;border-top: 5px solid white;border-bottom: none;"></td>
</tr>
</table>
"@

$footerObj = @"
<table>
<tr>
<td style="height: 15px;background-color: #ffffff;border: none;color: #626365;font-size: 10px;text-align:center;</a></td>
</tr>
</table>
</center>
</body>
</html>
"@



$BodySummHeader = @"
<table>

<tr>
<td style="height: 24px;border: none;background-color: #ffffff;color: Black;font-size: 15px;vertical-align: bottom;text-align: center;padding: 0px 0px 0px 15px;">Backups</td>
</tr>
</table>

"@

$Signature = @"
Checked By:______________________________ Date:______________________________ Authorised:______________________________ Date:______________________________
"@

$Result1= @{}
$Result2= @{}
$Result3= @{}
$Result4= @{}
$Result5= @{}
$Result6= @{}
$Result7= @{}
$Result8= @{}
$Result9= @{}

#This sets up the number of days that will be removed from today for the report dates
$Day9='-9'
$Day8='-8'
$Day7='-7'
$Day6='-6'
$Day5='-5'
$Day4='-4'
$Day3='-3'
$Day2='-2'
$Day1='-1'
$Day0='0'

#As the backups only run Monday - Saturday, there are longer backup windows over the weekend
if ([DateTime]::Today.AddDays($Day9).DayOfWeek -ne "Saturday" -or "Sunday") {
$StartDate1 = [DateTime]::Today.AddDays($Day9).AddHours(16)
$EndDate1 = [DateTime]::Today.AddDays($Day8).AddHours(16)
$Date1=[DateTime]::Today.AddDays($Day9).ToString("ddd d MMM yyy")
}
elseif ([DateTime]::Today.AddDays($Day9).DayOfWeek -eq "Saturday") {
$StartDate1 = [DateTime]::Today.AddDays($Day9).AddHours(16)
$EndDate1 = [DateTime]::Today.AddDays($Day7).AddHours(05)
$Date1=[DateTime]::Today.AddDays($Day9).ToString("ddd d MMM yyy")
}
elseif ([DateTime]::Today.AddDays($Day9).DayOfWeek -eq "Sunday") {
$Date1=[DateTime]::Today.AddDays($Day9).ToString("ddd d MMM yyy")
$StartDate1 = [DateTime]::Today.AddDays($Day0).AddHours(16)
$EndDate1 = [DateTime]::Today.AddDays($Day0).AddHours(16)
}

if ([DateTime]::Today.AddDays($Day8).DayOfWeek -ne "Saturday" -or "Sunday") {
$StartDate2 = [DateTime]::Today.AddDays($Day8).AddHours(16)
$EndDate2 = [DateTime]::Today.AddDays($Day7).AddHours(16)
$Date2=[DateTime]::Today.AddDays($Day8).ToString("ddd d MMM yyy")
}
elseif ([DateTime]::Today.AddDays($Day8).DayOfWeek -eq "Saturday") {
$StartDate2 = [DateTime]::Today.AddDays($Day8).AddHours(16)
$EndDate2 = [DateTime]::Today.AddDays($Day6).AddHours(05)
$Date2=[DateTime]::Today.AddDays($Day8).ToString("ddd d MMM yyy")
}
elseif ([DateTime]::Today.AddDays($Day8).DayOfWeek -eq "Sunday") {
$Date2=[DateTime]::Today.AddDays($Day8).ToString("ddd d MMM yyy")
$StartDate2 = [DateTime]::Today.AddDays($Day0).AddHours(16)
$EndDate2 = [DateTime]::Today.AddDays($Day0).AddHours(16)
}

if ([DateTime]::Today.AddDays($Day7).DayOfWeek -ne "Saturday" -or "Sunday") {
$StartDate3 = [DateTime]::Today.AddDays($Day7).AddHours(16)
$EndDate3 = [DateTime]::Today.AddDays($Day6).AddHours(16)
$Date3=[DateTime]::Today.AddDays($Day7).ToString("ddd d MMM yyy")
}
elseif ([DateTime]::Today.AddDays($Day7).DayOfWeek -eq "Saturday") {
$StartDate3 = [DateTime]::Today.AddDays($Day7).AddHours(16)
$EndDate3 = [DateTime]::Today.AddDays($Day5).AddHours(05)
$Date3=[DateTime]::Today.AddDays($Day7).ToString("ddd d MMM yyy")
}
elseif ([DateTime]::Today.AddDays($Day7).DayOfWeek -eq "Sunday") {
$Date3=[DateTime]::Today.AddDays($Day7).ToString("ddd d MMM yyy")
$StartDate3 = [DateTime]::Today.AddDays($Day0).AddHours(16)
$EndDate3 = [DateTime]::Today.AddDays($Day0).AddHours(16)
}

if ([DateTime]::Today.AddDays($Day6).DayOfWeek -ne "Saturday" -or "Sunday") {
$StartDate4 = [DateTime]::Today.AddDays($Day6).AddHours(16)
$EndDate4 = [DateTime]::Today.AddDays($Day5).AddHours(16)
$Date4=[DateTime]::Today.AddDays($Day6).ToString("ddd d MMM yyy")
}
elseif ([DateTime]::Today.AddDays($Day6).DayOfWeek -eq "Saturday") {
$StartDate4 = [DateTime]::Today.AddDays($Day6).AddHours(16)
$EndDate4 = [DateTime]::Today.AddDays($Day4).AddHours(05)
$Date4=[DateTime]::Today.AddDays($Day6).ToString("ddd d MMM yyy")
}
elseif ([DateTime]::Today.AddDays($Day6).DayOfWeek -eq "Sunday") {
$Date4=[DateTime]::Today.AddDays($Day6).ToString("ddd d MMM yyy")
$StartDate4 = [DateTime]::Today.AddDays($Day0).AddHours(16)
$EndDate4 = [DateTime]::Today.AddDays($Day0).AddHours(16)
}

if ([DateTime]::Today.AddDays($Day5).DayOfWeek -ne "Saturday" -or "Sunday") {
$StartDate5 = [DateTime]::Today.AddDays($Day5).AddHours(16)
$EndDate5 = [DateTime]::Today.AddDays($Day4).AddHours(16)
$Date5=[DateTime]::Today.AddDays($Day5).ToString("ddd d MMM yyy")
}
elseif ([DateTime]::Today.AddDays($Day5).DayOfWeek -eq "Saturday") {
$StartDate5 = [DateTime]::Today.AddDays($Day5).AddHours(16)
$EndDate5 = [DateTime]::Today.AddDays($Day3).AddHours(05)
$Date5=[DateTime]::Today.AddDays($Day5).ToString("ddd d MMM yyy")
}
elseif ([DateTime]::Today.AddDays($Day5).DayOfWeek -eq "Sunday") {
$Date5=[DateTime]::Today.AddDays($Day5).ToString("ddd d MMM yyy")
$StartDate5 = [DateTime]::Today.AddDays($Day0).AddHours(16)
$EndDate5 = [DateTime]::Today.AddDays($Day0).AddHours(16)
}

if ([DateTime]::Today.AddDays($Day4).DayOfWeek -ne "Saturday" -or "Sunday") {
$StartDate6 = [DateTime]::Today.AddDays($Day4).AddHours(16)
$EndDate6 = [DateTime]::Today.AddDays($Day3).AddHours(16)
$Date6=[DateTime]::Today.AddDays($Day4).ToString("ddd d MMM yyy")
}
elseif ([DateTime]::Today.AddDays($Day4).DayOfWeek -eq "Saturday") {
$StartDate6 = [DateTime]::Today.AddDays($Day4).AddHours(16)
$EndDate6 = [DateTime]::Today.AddDays($Day2).AddHours(05)
$Date6=[DateTime]::Today.AddDays($Day4).ToString("ddd d MMM yyy")
}
elseif ([DateTime]::Today.AddDays($Day4).DayOfWeek -eq "Sunday") {
$Date6=[DateTime]::Today.AddDays($Day4).ToString("ddd d MMM yyy")
$StartDate6 = [DateTime]::Today.AddDays($Day0).AddHours(16)
$EndDate6 = [DateTime]::Today.AddDays($Day0).AddHours(16)
}

if ([DateTime]::Today.AddDays($Day3).DayOfWeek -ne "Saturday" -or "Sunday") {
$StartDate7 = [DateTime]::Today.AddDays($Day3).AddHours(16)
$EndDate7 = [DateTime]::Today.AddDays($Day2).AddHours(16)
$Date7=[DateTime]::Today.AddDays($Day3).ToString("ddd d MMM yyy")
}
elseif ([DateTime]::Today.AddDays($Day3).DayOfWeek -eq "Saturday") {
$StartDate7 = [DateTime]::Today.AddDays($Day3).AddHours(16)
$EndDate7 = [DateTime]::Today.AddDays($Day1).AddHours(05)
$Date7=[DateTime]::Today.AddDays($Day3).ToString("ddd d MMM yyy")
}
elseif ([DateTime]::Today.AddDays($Day3).DayOfWeek -eq "Sunday") {
$Date7=[DateTime]::Today.AddDays($Day3).ToString("ddd d MMM yyy")
$StartDate7 = [DateTime]::Today.AddDays($Day0).AddHours(16)
$EndDate7 = [DateTime]::Today.AddDays($Day0).AddHours(16)
}



if ([DateTime]::Today.AddDays($Day2).DayOfWeek -ne "Saturday" -or "Sunday") {
$StartDate8 = [DateTime]::Today.AddDays($Day2).AddHours(16)
$EndDate8 = [DateTime]::Today.AddDays($Day1).AddHours(16)
$Date8=[DateTime]::Today.AddDays($Day2).ToString("ddd d MMM yyy")
}
elseif ([DateTime]::Today.AddDays($Day2).DayOfWeek -eq "Saturday") {
$StartDate8 = [DateTime]::Today.AddDays($Day2).AddHours(16)
$EndDate8 = [DateTime]::Today.AddDays($Day0).AddHours(05)
$Date8=[DateTime]::Today.AddDays($Day2).ToString("ddd d MMM yyy")
}
elseif ([DateTime]::Today.AddDays($Day2).DayOfWeek -eq "Sunday") {
$Date8=[DateTime]::Today.AddDays($Day2).ToString("ddd d MMM yyy")
$StartDate8 = [DateTime]::Today.AddDays($Day0).AddHours(16)
$EndDate8 = [DateTime]::Today.AddDays($Day0).AddHours(16)
}

if ([DateTime]::Today.AddDays($Day1).DayOfWeek -ne "Saturday" -or "Sunday") {
$StartDate9 = [DateTime]::Today.AddDays($Day1).AddHours(16)
$EndDate9 = [DateTime]::Today.AddDays($Day0).AddHours(16)
$Date9=[DateTime]::Today.AddDays($Day1).ToString("ddd d MMM yyy")
}
elseif ([DateTime]::Today.AddDays($Day1).DayOfWeek -eq "Saturday") {
$StartDate9 = [DateTime]::Today.AddDays($Day1).AddHours(16)
$EndDate9 = [DateTime]::Today.AddDays($Day0).AddHours(23)
$Date9=[DateTime]::Today.AddDays($Day1).ToString("ddd d MMM yyy")
}
elseif ([DateTime]::Today.AddDays($Day1).DayOfWeek -eq "Sunday") {
$Date9=[DateTime]::Today.AddDays($Day1).ToString("ddd d MMM yyy")
$StartDate9 = [DateTime]::Today.AddDays($Day0).AddHours(16)
$EndDate9 = [DateTime]::Today.AddDays($Day0).AddHours(16)
}


# This checks the backups for the virtual machines on the various dates and keeps the results for later
$BackupSessions1 = Get-VBRBackupSession | where {(($_.JobType -eq "Backup") -and ($_.CreationTime -ge $StartDate1) -and ($_.CreationTime -le $EndDate1))} | Sort JobName, CreationTime
$Result1 = & {
ForEach ($BackupSession1 in ($BackupSessions1 | ?{$_.IsRetryMode -eq $false})) {
[System.Collections.ArrayList]$TaskSessions1 = @($BackupSession1 | Get-VBRTaskSession)
If ($BackupSession1.Result -eq "Failed") {
$RetrySessions1 = $BackupSessions1 | ?{($_.IsRetryMode -eq $true) -and ($_.OriginalSessionId -eq $BackupSession1.Id)}
ForEach ($RetrySession1 in $RetrySessions1) {
[System.Collections.ArrayList]$RetryTaskSessions1 = @($RetrySession1 | Get-VBRTaskSession)
ForEach ($RetryTaskSession1 in $RetryTaskSessions1) {
$PriorTaskSession1 = $TaskSessions1 | ?{$_.Name -eq $RetryTaskSession1.Name}
If ($PriorTaskSession1) { $TaskSessions1.Remove($PriorTaskSession1) }
$TaskSessions1.Add($RetryTaskSession1) | Out-Null
}
}
}
$TaskSessions1 | Select @{N="JobName";E={$BackupSession1.JobName}},@{N="SessionName";E={$_.JobSess.Name}},@{N="JobResult";E={$_.JobSess.Result}},@{N="JobStart1";E={$_.JobSess.CreationTime}},@{N="JobEnd";E={$_.JobSess.EndTime}},@{N="Date";E={$_.JobSess.CreationTime.ToString("yyyy-MM-dd")}},name,@{N="Backup1";E={$_.Status}}

}
}


$BackupSessions2 = Get-VBRBackupSession | where {(($_.JobType -eq "Backup") -and ($_.CreationTime -ge $StartDate2) -and ($_.CreationTime -le $EndDate2))} | Sort JobName, CreationTime

$Result2 = & {
ForEach ($BackupSession2 in ($BackupSessions2 | ?{$_.IsRetryMode -eq $false})) {
[System.Collections.ArrayList]$TaskSessions2 = @($BackupSession2 | Get-VBRTaskSession)
If ($BackupSession2.Result -eq "Failed") {
$RetrySessions2 = $BackupSessions2 | ?{($_.IsRetryMode -eq $true) -and ($_.OriginalSessionId -eq $BackupSession2.Id)}
ForEach ($RetrySession2 in $RetrySessions2) {
[System.Collections.ArrayList]$RetryTaskSessions2 = @($RetrySession2 | Get-VBRTaskSession)
ForEach ($RetryTaskSession2 in $RetryTaskSessions2) {
$PriorTaskSession2 = $TaskSessions2 | ?{$_.Name -eq $RetryTaskSession2.Name}
If ($PriorTaskSession2) { $TaskSessions2.Remove($PriorTaskSession2) }
$TaskSessions2.Add($RetryTaskSession2) | Out-Null
}
}
}
$TaskSessions2 | Select @{N="JobName";E={$BackupSession2.JobName}},@{N="SessionName";E={$_.JobSess.Name}},@{N="JobResult";E={$_.JobSess.Result}},@{N="JobStart2";E={$_.JobSess.CreationTime}},@{N="JobEnd";E={$_.JobSess.EndTime}},@{N="Date";E={$_.JobSess.CreationTime.ToString("yyyy-MM-dd")}},name,@{N="Backup2";E={$_.Status}}#,status
}
}


$BackupSessions3 = Get-VBRBackupSession | where {(($_.JobType -eq "Backup") -and ($_.CreationTime -ge $StartDate3) -and ($_.CreationTime -le $EndDate3))} | Sort JobName, CreationTime

$Result3 = & {
ForEach ($BackupSession3 in ($BackupSessions3 | ?{{-not [string]::IsNullOrEmpty($_)} -and $_.IsRetryMode -eq $false})) {
[System.Collections.ArrayList]$TaskSessions3 = @($BackupSession3 | Get-VBRTaskSession)
If ($BackupSession3.Result -eq "Failed") {
$RetrySessions3 = $BackupSessions3 | ?{($_.IsRetryMode -eq $true) -and ($_.OriginalSessionId -eq $BackupSession3.Id) }
ForEach ($RetrySession3 in $RetrySessions3) {
[System.Collections.ArrayList]$RetryTaskSessions3 = @($RetrySession3 | Get-VBRTaskSession)
ForEach ($RetryTaskSession3 in $RetryTaskSessions3) {
$PriorTaskSession3 = $TaskSessions3 | ?{$_.Name -eq $RetryTaskSession3.Name}
If ($PriorTaskSession3) { $TaskSessions3.Remove($PriorTaskSession3) }
$TaskSessions3.Add($RetryTaskSession3) | Out-Null
}
}
}
$TaskSessions3 | Select @{N="JobName3";E={$BackupSession3.JobName}},@{N="SessionName3";E={$_.JobSess.Name}},@{N="JobResult3";E={$_.JobSess.Result}},@{N="JobStart3";E={$_.JobSess.CreationTime}},@{N="JobEnd3";E={$_.JobSess.EndTime}},@{N="Date3";E={$_.JobSess.CreationTime.ToString("yyyy-MM-dd")}},name,@{N="Backup3";E={$_.Status}}#,status
}
}

$BackupSessions4 = Get-VBRBackupSession | where {(($_.JobType -eq "Backup") -and ($_.CreationTime -ge $StartDate4) -and ($_.CreationTime -le $EndDate4))} | Sort JobName, CreationTime

$Result4 = & {
ForEach ($BackupSession4 in ($BackupSessions4 | ?{{-not [string]::IsNullOrEmpty($_)} -and $_.IsRetryMode -eq $false})) {
[System.Collections.ArrayList]$TaskSessions4 = @($BackupSession4 | Get-VBRTaskSession)
If ($BackupSession4.Result -eq "Failed") {
$RetrySessions4 = $BackupSessions4 | ?{($_.IsRetryMode -eq $true) -and ($_.OriginalSessionId -eq $BackupSession4.Id) }
ForEach ($RetrySession4 in $RetrySessions4) {
[System.Collections.ArrayList]$RetryTaskSessions4 = @($RetrySession4 | Get-VBRTaskSession)
ForEach ($RetryTaskSession4 in $RetryTaskSessions4) {
$PriorTaskSession4 = $TaskSessions4 | ?{$_.Name -eq $RetryTaskSession4.Name}
If ($PriorTaskSession4) { $TaskSessions4.Remove($PriorTaskSession4) }
$TaskSessions4.Add($RetryTaskSession4) | Out-Null
}
}
}
$TaskSessions4 | Select @{N="JobName4";E={$BackupSession4.JobName}},@{N="SessionName4";E={$_.JobSess.Name}},@{N="JobResult4";E={$_.JobSess.Result}},@{N="JobStart4";E={$_.JobSess.CreationTime}},@{N="JobEnd4";E={$_.JobSess.EndTime}},@{N="Date4";E={$_.JobSess.CreationTime.ToString("yyyy-MM-dd")}},name,@{N="Backup4";E={$_.Status}}#,status
}
}

$BackupSessions5 = Get-VBRBackupSession | where {(($_.JobType -eq "Backup") -and ($_.CreationTime -ge $StartDate5) -and ($_.CreationTime -le $EndDate5))} | Sort JobName, CreationTime

$Result5 = & {
ForEach ($BackupSession5 in ($BackupSessions5 | ?{{-not [string]::IsNullOrEmpty($_)} -and $_.IsRetryMode -eq $false})) {
[System.Collections.ArrayList]$TaskSessions5 = @($BackupSession5 | Get-VBRTaskSession)
If ($BackupSession5.Result -eq "Failed") {
$RetrySessions5 = $BackupSessions5 | ?{($_.IsRetryMode -eq $true) -and ($_.OriginalSessionId -eq $BackupSession5.Id) }
ForEach ($RetrySession5 in $RetrySessions5) {
[System.Collections.ArrayList]$RetryTaskSessions5 = @($RetrySession5 | Get-VBRTaskSession)
ForEach ($RetryTaskSession5 in $RetryTaskSessions5) {
$PriorTaskSession5 = $TaskSessions5 | ?{$_.Name -eq $RetryTaskSession5.Name}
If ($PriorTaskSession5) { $TaskSessions5.Remove($PriorTaskSession5) }
$TaskSessions5.Add($RetryTaskSession5) | Out-Null
}
}
}
$TaskSessions5 | Select @{N="JobName5";E={$BackupSession5.JobName}},@{N="SessionName5";E={$_.JobSess.Name}},@{N="JobResult5";E={$_.JobSess.Result}},@{N="JobStart5";E={$_.JobSess.CreationTime}},@{N="JobEnd5";E={$_.JobSess.EndTime}},@{N="Date5";E={$_.JobSess.CreationTime.ToString("yyyy-MM-dd")}},name,@{N="Backup5";E={$_.Status}}#,status
}
}

$BackupSessions6 = Get-VBRBackupSession | where {(($_.JobType -eq "Backup") -and ($_.CreationTime -ge $StartDate6) -and ($_.CreationTime -le $EndDate6))} | Sort JobName, CreationTime

$Result6 = & {
ForEach ($BackupSession6 in ($BackupSessions6 | ?{{-not [string]::IsNullOrEmpty($_)} -and $_.IsRetryMode -eq $false})) {
[System.Collections.ArrayList]$TaskSessions6 = @($BackupSession6 | Get-VBRTaskSession)
If ($BackupSession6.Result -eq "Failed") {
$RetrySessions6 = $BackupSessions6 | ?{($_.IsRetryMode -eq $true) -and ($_.OriginalSessionId -eq $BackupSession6.Id) }
ForEach ($RetrySession6 in $RetrySessions6) {
[System.Collections.ArrayList]$RetryTaskSessions6 = @($RetrySession6 | Get-VBRTaskSession)
ForEach ($RetryTaskSession6 in $RetryTaskSessions6) {
$PriorTaskSession6 = $TaskSessions6 | ?{$_.Name -eq $RetryTaskSession6.Name}
If ($PriorTaskSession6) { $TaskSessions6.Remove($PriorTaskSession6) }
$TaskSessions6.Add($RetryTaskSession6) | Out-Null
}
}
}
$TaskSessions6 | Select @{N="JobName6";E={$BackupSession6.JobName}},@{N="SessionName6";E={$_.JobSess.Name}},@{N="JobResult6";E={$_.JobSess.Result}},@{N="JobStart6";E={$_.JobSess.CreationTime}},@{N="JobEnd6";E={$_.JobSess.EndTime}},@{N="Date6";E={$_.JobSess.CreationTime.ToString("yyyy-MM-dd")}},name,@{N="Backup6";E={$_.Status}}#,status
}
}

$BackupSessions7 = Get-VBRBackupSession | where {(($_.JobType -eq "Backup") -and ($_.CreationTime -ge $StartDate7) -and ($_.CreationTime -le $EndDate7))} | Sort JobName, CreationTime

$Result7 = & {
ForEach ($BackupSession7 in ($BackupSessions7 | ?{{-not [string]::IsNullOrEmpty($_)} -and $_.IsRetryMode -eq $false})) {
[System.Collections.ArrayList]$TaskSessions7 = @($BackupSession7 | Get-VBRTaskSession)
If ($BackupSession7.Result -eq "Failed") {
$RetrySessions7 = $BackupSessions7 | ?{($_.IsRetryMode -eq $true) -and ($_.OriginalSessionId -eq $BackupSession7.Id) }
ForEach ($RetrySession7 in $RetrySessions7) {
[System.Collections.ArrayList]$RetryTaskSessions7 = @($RetrySession7 | Get-VBRTaskSession)
ForEach ($RetryTaskSession7 in $RetryTaskSessions7) {
$PriorTaskSession7 = $TaskSessions7 | ?{$_.Name -eq $RetryTaskSession7.Name}
If ($PriorTaskSession7) { $TaskSessions7.Remove($PriorTaskSession7) }
$TaskSessions7.Add($RetryTaskSession7) | Out-Null
}
}
}
$TaskSessions7 | Select @{N="JobName7";E={$BackupSession7.JobName}},@{N="SessionName7";E={$_.JobSess.Name}},@{N="JobResult7";E={$_.JobSess.Result}},@{N="JobStart7";E={$_.JobSess.CreationTime}},@{N="JobEnd7";E={$_.JobSess.EndTime}},@{N="Date7";E={$_.JobSess.CreationTime.ToString("yyyy-MM-dd")}},name,@{N="Backup7";E={$_.Status}}#,status
}
}

$BackupSessions8 = Get-VBRBackupSession | where {(($_.JobType -eq "Backup") -and ($_.CreationTime -ge $StartDate8) -and ($_.CreationTime -le $EndDate8))} | Sort JobName, CreationTime

$Result8 = & {
ForEach ($BackupSession8 in ($BackupSessions8 | ?{{-not [string]::IsNullOrEmpty($_)} -and $_.IsRetryMode -eq $false})) {
[System.Collections.ArrayList]$TaskSessions8 = @($BackupSession8 | Get-VBRTaskSession)
If ($BackupSession8.Result -eq "Failed") {
$RetrySessions8 = $BackupSessions8 | ?{($_.IsRetryMode -eq $true) -and ($_.OriginalSessionId -eq $BackupSession8.Id) }
ForEach ($RetrySession8 in $RetrySessions8) {
[System.Collections.ArrayList]$RetryTaskSessions8 = @($RetrySession8 | Get-VBRTaskSession)
ForEach ($RetryTaskSession8 in $RetryTaskSessions8) {
$PriorTaskSession8 = $TaskSessions8 | ?{$_.Name -eq $RetryTaskSession8.Name}
If ($PriorTaskSession8) { $TaskSessions8.Remove($PriorTaskSession8) }
$TaskSessions8.Add($RetryTaskSession8) | Out-Null
}
}
}
$TaskSessions8 | Select @{N="JobName8";E={$BackupSession8.JobName}},@{N="SessionName8";E={$_.JobSess.Name}},@{N="JobResult8";E={$_.JobSess.Result}},@{N="JobStart8";E={$_.JobSess.CreationTime}},@{N="JobEnd8";E={$_.JobSess.EndTime}},@{N="Date8";E={$_.JobSess.CreationTime.ToString("yyyy-MM-dd")}},name,@{N="Backup8";E={$_.Status}}#,status
}
}

$BackupSessions9 = Get-VBRBackupSession | where {(($_.JobType -eq "Backup") -and ($_.CreationTime -ge $StartDate9) -and ($_.CreationTime -le $EndDate9))} | Sort JobName, CreationTime

$Result9 = & {
ForEach ($BackupSession9 in ($BackupSessions9 | ?{{-not [string]::IsNullOrEmpty($_)} -and $_.IsRetryMode -eq $false})) {
[System.Collections.ArrayList]$TaskSessions9 = @($BackupSession9 | Get-VBRTaskSession)
If ($BackupSession9.Result -eq "Failed") {
$RetrySessions9 = $BackupSessions9 | ?{($_.IsRetryMode -eq $true) -and ($_.OriginalSessionId -eq $BackupSession9.Id) }
ForEach ($RetrySession9 in $RetrySessions9) {
[System.Collections.ArrayList]$RetryTaskSessions9 = @($RetrySession9 | Get-VBRTaskSession)
ForEach ($RetryTaskSession9 in $RetryTaskSessions9) {
$PriorTaskSession9 = $TaskSessions9 | ?{$_.Name -eq $RetryTaskSession9.Name}
If ($PriorTaskSession9) { $TaskSessions9.Remove($PriorTaskSession9) }
$TaskSessions9.Add($RetryTaskSession9) | Out-Null
}
}
}
$TaskSessions9 | Select @{N="JobName9";E={$BackupSession9.JobName}},@{N="SessionName9";E={$_.JobSess.Name}},@{N="JobResult9";E={$_.JobSess.Result}},@{N="JobStart9";E={$_.JobSess.CreationTime}},@{N="JobEnd9";E={$_.JobSess.EndTime}},@{N="Date9";E={$_.JobSess.CreationTime.ToString("yyyy-MM-dd")}},name,@{N="Backup9";E={$_.Status}}#,status
}
}


$EndResult = $Result1+$Result2+$Result3+$Result4+$Result5+$Result6+$Result7+$Result8+$Result9


#This now references through the results to find the relevant result for each VM on each day
#It will check whether the backup date is a Sunday and exclude those days, and also change the column name of the Saturday
#before to show 'Weekend of ' instead of just the date
if ([DateTime]::Today.AddDays($Day8).DayOfWeek -eq "Sunday") {
Write-Host "Combined"
$bodySummaryRp = $EndResult | Group Name | ForEach {
New-Object PSObject -Property @{
Name = $_.Name
Backup1 = if ($_.Group[0].Backup1 -ne $null) {
($_.Group[0].Backup1)}
elseif ($_.Group[1].Backup1 -ne $null) {
($_.Group[1].Backup1)}
elseif ($_.Group[2].Backup1 -ne $null) {
($_.Group[2].Backup1)}
elseif ($_.Group[3].Backup1 -ne $null) {
($_.Group[3].Backup1)}
elseif ($_.Group[4].Backup1 -ne $null) {
($_.Group[4].Backup1)}
elseif ($_.Group[5].Backup1 -ne $null) {
($_.Group[5].Backup1)}
elseif ($_.Group[6].Backup1 -ne $null) {
($_.Group[6].Backup1)}
elseif ($_.Group[7].Backup1 -ne $null) {
($_.Group[7].Backup1)}
elseif ($_.Group[8].Backup1 -ne $null) {
($_.Group[8].Backup1)}
elseif ($_.Group[9].Backup1 -ne $null) {
($_.Group[9].Backup1)}
elseif ($_.Group[10].Backup1 -ne $null) {
($_.Group[10].Backup1)};
Backup3 = if ($_.Group[0].Backup3 -ne $null) {
($_.Group[0].Backup3)}
elseif ($_.Group[1].Backup3 -ne $null) {
($_.Group[1].Backup3)}
elseif ($_.Group[2].Backup3 -ne $null) {
($_.Group[2].Backup3)}
elseif ($_.Group[3].Backup3 -ne $null) {
($_.Group[3].Backup3)}
elseif ($_.Group[4].Backup3 -ne $null) {
($_.Group[4].Backup3)}
elseif ($_.Group[5].Backup3 -ne $null) {
($_.Group[5].Backup3)}
elseif ($_.Group[6].Backup3 -ne $null) {
($_.Group[6].Backup3)}
elseif ($_.Group[7].Backup3 -ne $null) {
($_.Group[7].Backup3)}
elseif ($_.Group[8].Backup3 -ne $null) {
($_.Group[8].Backup3)}
elseif ($_.Group[9].Backup3 -ne $null) {
($_.Group[9].Backup3)}
elseif ($_.Group[10].Backup3 -ne $null) {
($_.Group[10].Backup3)};
Backup4 = if ($_.Group[0].Backup4 -ne $null) {
($_.Group[0].Backup4)}
elseif ($_.Group[1].Backup4 -ne $null) {
($_.Group[1].Backup4)}
elseif ($_.Group[2].Backup4 -ne $null) {
($_.Group[2].Backup4)}
elseif ($_.Group[3].Backup4 -ne $null) {
($_.Group[3].Backup4)}
elseif ($_.Group[4].Backup4 -ne $null) {
($_.Group[4].Backup4)}
elseif ($_.Group[5].Backup4 -ne $null) {
($_.Group[5].Backup4)}
elseif ($_.Group[6].Backup4 -ne $null) {
($_.Group[6].Backup4)}
elseif ($_.Group[7].Backup4 -ne $null) {
($_.Group[7].Backup4)}
elseif ($_.Group[8].Backup4 -ne $null) {
($_.Group[8].Backup4)}
elseif ($_.Group[9].Backup4 -ne $null) {
($_.Group[9].Backup4)}
elseif ($_.Group[10].Backup4 -ne $null) {
($_.Group[10].Backup4)};
Backup5 = if ($_.Group[0].Backup5 -ne $null) {
($_.Group[0].Backup5)}
elseif ($_.Group[1].Backup5 -ne $null) {
($_.Group[1].Backup5)}
elseif ($_.Group[2].Backup5 -ne $null) {
($_.Group[2].Backup5)}
elseif ($_.Group[3].Backup5 -ne $null) {
($_.Group[3].Backup5)}
elseif ($_.Group[4].Backup5 -ne $null) {
($_.Group[4].Backup5)}
elseif ($_.Group[5].Backup5 -ne $null) {
($_.Group[5].Backup5)}
elseif ($_.Group[6].Backup5 -ne $null) {
($_.Group[6].Backup5)}
elseif ($_.Group[7].Backup5 -ne $null) {
($_.Group[7].Backup5)}
elseif ($_.Group[8].Backup5 -ne $null) {
($_.Group[8].Backup5)}
elseif ($_.Group[9].Backup5 -ne $null) {
($_.Group[9].Backup5)}
elseif ($_.Group[10].Backup5 -ne $null) {
($_.Group[10].Backup5)};
Backup6 = if ($_.Group[0].Backup6 -ne $null) {
($_.Group[0].Backup6)}
elseif ($_.Group[1].Backup6 -ne $null) {
($_.Group[1].Backup6)}
elseif ($_.Group[2].Backup6 -ne $null) {
($_.Group[2].Backup6)}
elseif ($_.Group[3].Backup6 -ne $null) {
($_.Group[3].Backup6)}
elseif ($_.Group[4].Backup6 -ne $null) {
($_.Group[4].Backup6)}
elseif ($_.Group[5].Backup6 -ne $null) {
($_.Group[5].Backup6)}
elseif ($_.Group[6].Backup6 -ne $null) {
($_.Group[6].Backup6)}
elseif ($_.Group[7].Backup6 -ne $null) {
($_.Group[7].Backup6)}
elseif ($_.Group[8].Backup6 -ne $null) {
($_.Group[8].Backup6)}
elseif ($_.Group[9].Backup6 -ne $null) {
($_.Group[9].Backup6)}
elseif ($_.Group[10].Backup6 -ne $null) {
($_.Group[10].Backup6)};
Backup7 = if ($_.Group[0].Backup7 -ne $null) {
($_.Group[0].Backup7)}
elseif ($_.Group[1].Backup7 -ne $null) {
($_.Group[1].Backup7)}
elseif ($_.Group[2].Backup7 -ne $null) {
($_.Group[2].Backup7)}
elseif ($_.Group[3].Backup7 -ne $null) {
($_.Group[3].Backup7)}
elseif ($_.Group[4].Backup7 -ne $null) {
($_.Group[4].Backup7)}
elseif ($_.Group[5].Backup7 -ne $null) {
($_.Group[5].Backup7)}
elseif ($_.Group[6].Backup7 -ne $null) {
($_.Group[6].Backup7)}
elseif ($_.Group[7].Backup7 -ne $null) {
($_.Group[7].Backup7)}
elseif ($_.Group[8].Backup7 -ne $null) {
($_.Group[8].Backup7)}
elseif ($_.Group[9].Backup7 -ne $null) {
($_.Group[9].Backup7)}
elseif ($_.Group[10].Backup7 -ne $null) {
($_.Group[10].Backup7)};
Backup8 = if ($_.Group[0].Backup8 -ne $null) {
($_.Group[0].Backup8)}
elseif ($_.Group[1].Backup8 -ne $null) {
($_.Group[1].Backup8)}
elseif ($_.Group[2].Backup8 -ne $null) {
($_.Group[2].Backup8)}
elseif ($_.Group[3].Backup8 -ne $null) {
($_.Group[3].Backup8)}
elseif ($_.Group[4].Backup8 -ne $null) {
($_.Group[4].Backup8)}
elseif ($_.Group[5].Backup8 -ne $null) {
($_.Group[5].Backup8)}
elseif ($_.Group[6].Backup8 -ne $null) {
($_.Group[6].Backup8)}
elseif ($_.Group[7].Backup8 -ne $null) {
($_.Group[7].Backup8)}
elseif ($_.Group[8].Backup8 -ne $null) {
($_.Group[8].Backup8)}
elseif ($_.Group[9].Backup8 -ne $null) {
($_.Group[9].Backup8)}
elseif ($_.Group[10].Backup8 -ne $null) {
($_.Group[10].Backup8)};
}
} | select Name,@{N="Weekend of $Date1";E={$_.Backup1}},@{N="$Date3";E={$_.Backup3}},@{N="$Date4";E={$_.Backup4}},@{N="$Date5";E={$_.Backup5}},@{N="$Date6";E={$_.Backup6}},@{N="$Date7";E={$_.Backup7}},@{N="Weekend of $Date8";E={$_.Backup8}}| Sort Name | ConvertTo-Html -Fragment
} elseif ([DateTime]::Today.AddDays($Day7).DayOfWeek -eq "Sunday") {
Write-Host "Combined"
$ColumnDate = 'Weekend of ' + $Date1
$bodySummaryRp = $EndResult | Group Name | ForEach {
New-Object PSObject -Property @{
Name = $_.Name
Backup2 = if ($_.Group[0].Backup2 -ne $null) {
($_.Group[0].Backup2)}
elseif ($_.Group[1].Backup2 -ne $null) {
($_.Group[1].Backup2)}
elseif ($_.Group[2].Backup2 -ne $null) {
($_.Group[2].Backup2)}
elseif ($_.Group[3].Backup2 -ne $null) {
($_.Group[3].Backup2)}
elseif ($_.Group[4].Backup2 -ne $null) {
($_.Group[4].Backup2)}
elseif ($_.Group[5].Backup2 -ne $null) {
($_.Group[5].Backup2)}
elseif ($_.Group[6].Backup2 -ne $null) {
($_.Group[6].Backup2)}
elseif ($_.Group[7].Backup2 -ne $null) {
($_.Group[7].Backup2)}
elseif ($_.Group[8].Backup2 -ne $null) {
($_.Group[8].Backup2)}
elseif ($_.Group[9].Backup2 -ne $null) {
($_.Group[9].Backup2)}
elseif ($_.Group[10].Backup2 -ne $null) {
($_.Group[10].Backup2)};

Backup4 = if ($_.Group[0].Backup4 -ne $null) {
($_.Group[0].Backup4)}
elseif ($_.Group[1].Backup4 -ne $null) {
($_.Group[1].Backup4)}
elseif ($_.Group[2].Backup4 -ne $null) {
($_.Group[2].Backup4)}
elseif ($_.Group[3].Backup4 -ne $null) {
($_.Group[3].Backup4)}
elseif ($_.Group[4].Backup4 -ne $null) {
($_.Group[4].Backup4)}
elseif ($_.Group[5].Backup4 -ne $null) {
($_.Group[5].Backup4)}
elseif ($_.Group[6].Backup4 -ne $null) {
($_.Group[6].Backup4)}
elseif ($_.Group[7].Backup4 -ne $null) {
($_.Group[7].Backup4)}
elseif ($_.Group[8].Backup4 -ne $null) {
($_.Group[8].Backup4)}
elseif ($_.Group[9].Backup4 -ne $null) {
($_.Group[9].Backup4)}
elseif ($_.Group[10].Backup4 -ne $null) {
($_.Group[10].Backup4)};
Backup5 = if ($_.Group[0].Backup5 -ne $null) {
($_.Group[0].Backup5)}
elseif ($_.Group[1].Backup5 -ne $null) {
($_.Group[1].Backup5)}
elseif ($_.Group[2].Backup5 -ne $null) {
($_.Group[2].Backup5)}
elseif ($_.Group[3].Backup5 -ne $null) {
($_.Group[3].Backup5)}
elseif ($_.Group[4].Backup5 -ne $null) {
($_.Group[4].Backup5)}
elseif ($_.Group[5].Backup5 -ne $null) {
($_.Group[5].Backup5)}
elseif ($_.Group[6].Backup5 -ne $null) {
($_.Group[6].Backup5)}
elseif ($_.Group[7].Backup5 -ne $null) {
($_.Group[7].Backup5)}
elseif ($_.Group[8].Backup5 -ne $null) {
($_.Group[8].Backup5)}
elseif ($_.Group[9].Backup5 -ne $null) {
($_.Group[9].Backup5)}
elseif ($_.Group[10].Backup5 -ne $null) {
($_.Group[10].Backup5)};
Backup6 = if ($_.Group[0].Backup6 -ne $null) {
($_.Group[0].Backup6)}
elseif ($_.Group[1].Backup6 -ne $null) {
($_.Group[1].Backup6)}
elseif ($_.Group[2].Backup6 -ne $null) {
($_.Group[2].Backup6)}
elseif ($_.Group[3].Backup6 -ne $null) {
($_.Group[3].Backup6)}
elseif ($_.Group[4].Backup6 -ne $null) {
($_.Group[4].Backup6)}
elseif ($_.Group[5].Backup6 -ne $null) {
($_.Group[5].Backup6)}
elseif ($_.Group[6].Backup6 -ne $null) {
($_.Group[6].Backup6)}
elseif ($_.Group[7].Backup6 -ne $null) {
($_.Group[7].Backup6)}
elseif ($_.Group[8].Backup6 -ne $null) {
($_.Group[8].Backup6)}
elseif ($_.Group[9].Backup6 -ne $null) {
($_.Group[9].Backup6)}
elseif ($_.Group[10].Backup6 -ne $null) {
($_.Group[10].Backup6)};
Backup7 = if ($_.Group[0].Backup7 -ne $null) {
($_.Group[0].Backup7)}
elseif ($_.Group[1].Backup7 -ne $null) {
($_.Group[1].Backup7)}
elseif ($_.Group[2].Backup7 -ne $null) {
($_.Group[2].Backup7)}
elseif ($_.Group[3].Backup7 -ne $null) {
($_.Group[3].Backup7)}
elseif ($_.Group[4].Backup7 -ne $null) {
($_.Group[4].Backup7)}
elseif ($_.Group[5].Backup7 -ne $null) {
($_.Group[5].Backup7)}
elseif ($_.Group[6].Backup7 -ne $null) {
($_.Group[6].Backup7)}
elseif ($_.Group[7].Backup7 -ne $null) {
($_.Group[7].Backup7)}
elseif ($_.Group[8].Backup7 -ne $null) {
($_.Group[8].Backup7)}
elseif ($_.Group[9].Backup7 -ne $null) {
($_.Group[9].Backup7)}
elseif ($_.Group[10].Backup7 -ne $null) {
($_.Group[10].Backup7)};
Backup8 = if ($_.Group[0].Backup8 -ne $null) {
($_.Group[0].Backup8)}
elseif ($_.Group[1].Backup8 -ne $null) {
($_.Group[1].Backup8)}
elseif ($_.Group[2].Backup8 -ne $null) {
($_.Group[2].Backup8)}
elseif ($_.Group[3].Backup8 -ne $null) {
($_.Group[3].Backup8)}
elseif ($_.Group[4].Backup8 -ne $null) {
($_.Group[4].Backup8)}
elseif ($_.Group[5].Backup8 -ne $null) {
($_.Group[5].Backup8)}
elseif ($_.Group[6].Backup8 -ne $null) {
($_.Group[6].Backup8)}
elseif ($_.Group[7].Backup8 -ne $null) {
($_.Group[7].Backup8)}
elseif ($_.Group[8].Backup8 -ne $null) {
($_.Group[8].Backup8)}
elseif ($_.Group[9].Backup8 -ne $null) {
($_.Group[9].Backup8)}
elseif ($_.Group[10].Backup8 -ne $null) {
($_.Group[10].Backup8)};
Backup9 = if ($_.Group[0].Backup9 -ne $null) {
($_.Group[0].Backup9)}
elseif ($_.Group[1].Backup9 -ne $null) {
($_.Group[1].Backup9)}
elseif ($_.Group[2].Backup9 -ne $null) {
($_.Group[2].Backup9)}
elseif ($_.Group[3].Backup9 -ne $null) {
($_.Group[3].Backup9)}
elseif ($_.Group[4].Backup9 -ne $null) {
($_.Group[4].Backup9)}
elseif ($_.Group[5].Backup9 -ne $null) {
($_.Group[5].Backup9)}
elseif ($_.Group[6].Backup9 -ne $null) {
($_.Group[6].Backup9)}
elseif ($_.Group[7].Backup9 -ne $null) {
($_.Group[7].Backup9)}
elseif ($_.Group[8].Backup9 -ne $null) {
($_.Group[8].Backup9)}
elseif ($_.Group[9].Backup9 -ne $null) {
($_.Group[9].Backup9)}
elseif ($_.Group[10].Backup9 -ne $null) {
($_.Group[10].Backup9)};
}
} | Select Name,@{N="Weekend of $Date2";E={$_.Backup1}},@{N="$Date4";E={$_.Backup4}},@{N="$Date5";E={$_.Backup5}},@{N="$Date6";E={$_.Backup6}},@{N="$Date7";E={$_.Backup7}},@{N="$Date8";E={$_.Backup8}},@{N="Weekend of $Date9";E={$_.Backup9}} | Sort Name | ConvertTo-Html -Fragment # | set-cellcolor -Property $Date3 -Color red -Filter "$Date3 -like 'Failed'" | set-cellcolor -Property $Date3 -Color '#00ff00' -Filter "$Date3 -like 'Success'" | set-cellcolor -Property $Date3 -Color '#FFFF00' -Filter "$Date3 -like 'Warning'" #set-cellcolor -Property $Date3 -Color red -Filter "$Date3 -like 'Failed'" | set-cellcolor -Property $Date4 -Color red -Filter "$Date4 -like 'Failed'" | set-cellcolor -Property "Weekend of $Date1" -Color '#00ff00' -Filter "'Weekend of $Date1' -like 'Success'" | set-cellcolor -Property $Date3 -Color '#00ff00' -Filter "$Date3 -like 'Success'" | set-cellcolor -Property $Date4 -Color '#00ff00' -Filter "$Date4 -like 'Success'" | set-cellcolor -Property "Weekend of $Date1" -Color '#FFFF00' -Filter "'Weekend of $Date1' -like 'Warning'" | Out-File "D:\Scripts\New-BackupCheck\VeeamBackupReport.htm"
} elseif ([DateTime]::Today.AddDays($Day6).DayOfWeek -eq "Sunday") {
Write-Host "Combined"
$ColumnDate = 'Weekend of ' + $Date2
$bodySummaryRp = $EndResult | Group Name | ForEach {
New-Object PSObject -Property @{
Name = $_.Name

Backup2 = if ($_.Group[0].Backup2 -ne $null) {
($_.Group[0].Backup2)}
elseif ($_.Group[1].Backup2 -ne $null) {
($_.Group[1].Backup2)}
elseif ($_.Group[2].Backup2 -ne $null) {
($_.Group[2].Backup2)}
elseif ($_.Group[3].Backup2 -ne $null) {
($_.Group[3].Backup2)}
elseif ($_.Group[4].Backup2 -ne $null) {
($_.Group[4].Backup2)}
elseif ($_.Group[5].Backup2 -ne $null) {
($_.Group[5].Backup2)}
elseif ($_.Group[6].Backup2 -ne $null) {
($_.Group[6].Backup2)}
elseif ($_.Group[7].Backup2 -ne $null) {
($_.Group[7].Backup2)}
elseif ($_.Group[8].Backup2 -ne $null) {
($_.Group[8].Backup2)}
elseif ($_.Group[9].Backup2 -ne $null) {
($_.Group[9].Backup2)}
elseif ($_.Group[10].Backup2 -ne $null) {
($_.Group[10].Backup2)};
Backup3 = if ($_.Group[0].Backup3 -ne $null) {
($_.Group[0].Backup3)}
elseif ($_.Group[1].Backup3 -ne $null) {
($_.Group[1].Backup3)}
elseif ($_.Group[2].Backup3 -ne $null) {
($_.Group[2].Backup3)}
elseif ($_.Group[3].Backup3 -ne $null) {
($_.Group[3].Backup3)}
elseif ($_.Group[4].Backup3 -ne $null) {
($_.Group[4].Backup3)}
elseif ($_.Group[5].Backup3 -ne $null) {
($_.Group[5].Backup3)}
elseif ($_.Group[6].Backup3 -ne $null) {
($_.Group[6].Backup3)}
elseif ($_.Group[7].Backup3 -ne $null) {
($_.Group[7].Backup3)}
elseif ($_.Group[8].Backup3 -ne $null) {
($_.Group[8].Backup3)}
elseif ($_.Group[9].Backup3 -ne $null) {
($_.Group[9].Backup3)}
elseif ($_.Group[10].Backup3 -ne $null) {
($_.Group[10].Backup3)};

Backup5 = if ($_.Group[0].Backup5 -ne $null) {
($_.Group[0].Backup5)}
elseif ($_.Group[1].Backup5 -ne $null) {
($_.Group[1].Backup5)}
elseif ($_.Group[2].Backup5 -ne $null) {
($_.Group[2].Backup5)}
elseif ($_.Group[3].Backup5 -ne $null) {
($_.Group[3].Backup5)}
elseif ($_.Group[4].Backup5 -ne $null) {
($_.Group[4].Backup5)}
elseif ($_.Group[5].Backup5 -ne $null) {
($_.Group[5].Backup5)}
elseif ($_.Group[6].Backup5 -ne $null) {
($_.Group[6].Backup5)}
elseif ($_.Group[7].Backup5 -ne $null) {
($_.Group[7].Backup5)}
elseif ($_.Group[8].Backup5 -ne $null) {
($_.Group[8].Backup5)}
elseif ($_.Group[9].Backup5 -ne $null) {
($_.Group[9].Backup5)}
elseif ($_.Group[10].Backup5 -ne $null) {
($_.Group[10].Backup5)};
Backup6 = if ($_.Group[0].Backup6 -ne $null) {
($_.Group[0].Backup6)}
elseif ($_.Group[1].Backup6 -ne $null) {
($_.Group[1].Backup6)}
elseif ($_.Group[2].Backup6 -ne $null) {
($_.Group[2].Backup6)}
elseif ($_.Group[3].Backup6 -ne $null) {
($_.Group[3].Backup6)}
elseif ($_.Group[4].Backup6 -ne $null) {
($_.Group[4].Backup6)}
elseif ($_.Group[5].Backup6 -ne $null) {
($_.Group[5].Backup6)}
elseif ($_.Group[6].Backup6 -ne $null) {
($_.Group[6].Backup6)}
elseif ($_.Group[7].Backup6 -ne $null) {
($_.Group[7].Backup6)}
elseif ($_.Group[8].Backup6 -ne $null) {
($_.Group[8].Backup6)}
elseif ($_.Group[9].Backup6 -ne $null) {
($_.Group[9].Backup6)}
elseif ($_.Group[10].Backup6 -ne $null) {
($_.Group[10].Backup6)};
Backup7 = if ($_.Group[0].Backup7 -ne $null) {
($_.Group[0].Backup7)}
elseif ($_.Group[1].Backup7 -ne $null) {
($_.Group[1].Backup7)}
elseif ($_.Group[2].Backup7 -ne $null) {
($_.Group[2].Backup7)}
elseif ($_.Group[3].Backup7 -ne $null) {
($_.Group[3].Backup7)}
elseif ($_.Group[4].Backup7 -ne $null) {
($_.Group[4].Backup7)}
elseif ($_.Group[5].Backup7 -ne $null) {
($_.Group[5].Backup7)}
elseif ($_.Group[6].Backup7 -ne $null) {
($_.Group[6].Backup7)}
elseif ($_.Group[7].Backup7 -ne $null) {
($_.Group[7].Backup7)}
elseif ($_.Group[8].Backup7 -ne $null) {
($_.Group[8].Backup7)}
elseif ($_.Group[9].Backup7 -ne $null) {
($_.Group[9].Backup7)}
elseif ($_.Group[10].Backup7 -ne $null) {
($_.Group[10].Backup7)};
Backup8 = if ($_.Group[0].Backup8 -ne $null) {
($_.Group[0].Backup8)}
elseif ($_.Group[1].Backup8 -ne $null) {
($_.Group[1].Backup8)}
elseif ($_.Group[2].Backup8 -ne $null) {
($_.Group[2].Backup8)}
elseif ($_.Group[3].Backup8 -ne $null) {
($_.Group[3].Backup8)}
elseif ($_.Group[4].Backup8 -ne $null) {
($_.Group[4].Backup8)}
elseif ($_.Group[5].Backup8 -ne $null) {
($_.Group[5].Backup8)}
elseif ($_.Group[6].Backup8 -ne $null) {
($_.Group[6].Backup8)}
elseif ($_.Group[7].Backup8 -ne $null) {
($_.Group[7].Backup8)}
elseif ($_.Group[8].Backup8 -ne $null) {
($_.Group[8].Backup8)}
elseif ($_.Group[9].Backup8 -ne $null) {
($_.Group[9].Backup8)}
elseif ($_.Group[10].Backup8 -ne $null) {
($_.Group[10].Backup8)};
Backup9 = if ($_.Group[0].Backup9 -ne $null) {
($_.Group[0].Backup9)}
elseif ($_.Group[1].Backup9 -ne $null) {
($_.Group[1].Backup9)}
elseif ($_.Group[2].Backup9 -ne $null) {
($_.Group[2].Backup9)}
elseif ($_.Group[3].Backup9 -ne $null) {
($_.Group[3].Backup9)}
elseif ($_.Group[4].Backup9 -ne $null) {
($_.Group[4].Backup9)}
elseif ($_.Group[5].Backup9 -ne $null) {
($_.Group[5].Backup9)}
elseif ($_.Group[6].Backup9 -ne $null) {
($_.Group[6].Backup9)}
elseif ($_.Group[7].Backup9 -ne $null) {
($_.Group[7].Backup9)}
elseif ($_.Group[8].Backup9 -ne $null) {
($_.Group[8].Backup9)}
elseif ($_.Group[9].Backup9 -ne $null) {
($_.Group[9].Backup9)}
elseif ($_.Group[10].Backup9 -ne $null) {
($_.Group[10].Backup9)};
}
} | select Name,@{N="$Date2";E={$_.Backup2}},@{N="Weekend of $Date3";E={$_.Backup3}},@{N="$Date5";E={$_.Backup5}},@{N="$Date6";E={$_.Backup6}},@{N="$Date7";E={$_.Backup7}},@{N="$Date8";E={$_.Backup8}},@{N="$Date9";E={$_.Backup9}} | Sort Name | ConvertTo-Html -Fragment #| set-cellcolor -Property $Date1 -Color red -Filter "$Date1 -like 'Failed'" | set-cellcolor -Property $Date1 -Color '#00ff00' -Filter "$Date1 -like 'Success'" | set-cellcolor -Property $Date1 -Color '#FFFF00' -Filter "$Date1 -like 'Warning'"

} elseif ([DateTime]::Today.AddDays($Day5).DayOfWeek -eq "Sunday") {
Write-Host "Combined"
$bodySummaryRp = $EndResult | Group Name | ForEach {
New-Object PSObject -Property @{
Name = $_.Name

Backup2 = if ($_.Group[0].Backup2 -ne $null) {
($_.Group[0].Backup2)}
elseif ($_.Group[1].Backup2 -ne $null) {
($_.Group[1].Backup2)}
elseif ($_.Group[2].Backup2 -ne $null) {
($_.Group[2].Backup2)}
elseif ($_.Group[3].Backup2 -ne $null) {
($_.Group[3].Backup2)}
elseif ($_.Group[4].Backup2 -ne $null) {
($_.Group[4].Backup2)}
elseif ($_.Group[5].Backup2 -ne $null) {
($_.Group[5].Backup2)}
elseif ($_.Group[6].Backup2 -ne $null) {
($_.Group[6].Backup2)}
elseif ($_.Group[7].Backup2 -ne $null) {
($_.Group[7].Backup2)}
elseif ($_.Group[8].Backup2 -ne $null) {
($_.Group[8].Backup2)}
elseif ($_.Group[9].Backup2 -ne $null) {
($_.Group[9].Backup2)}
elseif ($_.Group[10].Backup2 -ne $null) {
($_.Group[10].Backup2)};
Backup3 = if ($_.Group[0].Backup3 -ne $null) {
($_.Group[0].Backup3)}
elseif ($_.Group[1].Backup3 -ne $null) {
($_.Group[1].Backup3)}
elseif ($_.Group[2].Backup3 -ne $null) {
($_.Group[2].Backup3)}
elseif ($_.Group[3].Backup3 -ne $null) {
($_.Group[3].Backup3)}
elseif ($_.Group[4].Backup3 -ne $null) {
($_.Group[4].Backup3)}
elseif ($_.Group[5].Backup3 -ne $null) {
($_.Group[5].Backup3)}
elseif ($_.Group[6].Backup3 -ne $null) {
($_.Group[6].Backup3)}
elseif ($_.Group[7].Backup3 -ne $null) {
($_.Group[7].Backup3)}
elseif ($_.Group[8].Backup3 -ne $null) {
($_.Group[8].Backup3)}
elseif ($_.Group[9].Backup3 -ne $null) {
($_.Group[9].Backup3)}
elseif ($_.Group[10].Backup3 -ne $null) {
($_.Group[10].Backup3)};
Backup4 = if ($_.Group[0].Backup4 -ne $null) {
($_.Group[0].Backup4)}
elseif ($_.Group[1].Backup4 -ne $null) {
($_.Group[1].Backup4)}
elseif ($_.Group[2].Backup4 -ne $null) {
($_.Group[2].Backup4)}
elseif ($_.Group[3].Backup4 -ne $null) {
($_.Group[3].Backup4)}
elseif ($_.Group[4].Backup4 -ne $null) {
($_.Group[4].Backup4)}
elseif ($_.Group[5].Backup4 -ne $null) {
($_.Group[5].Backup4)}
elseif ($_.Group[6].Backup4 -ne $null) {
($_.Group[6].Backup4)}
elseif ($_.Group[7].Backup4 -ne $null) {
($_.Group[7].Backup4)}
elseif ($_.Group[8].Backup4 -ne $null) {
($_.Group[8].Backup4)}
elseif ($_.Group[9].Backup4 -ne $null) {
($_.Group[9].Backup4)}
elseif ($_.Group[10].Backup4 -ne $null) {
($_.Group[10].Backup4)};

Backup6 = if ($_.Group[0].Backup6 -ne $null) {
($_.Group[0].Backup6)}
elseif ($_.Group[1].Backup6 -ne $null) {
($_.Group[1].Backup6)}
elseif ($_.Group[2].Backup6 -ne $null) {
($_.Group[2].Backup6)}
elseif ($_.Group[3].Backup6 -ne $null) {
($_.Group[3].Backup6)}
elseif ($_.Group[4].Backup6 -ne $null) {
($_.Group[4].Backup6)}
elseif ($_.Group[5].Backup6 -ne $null) {
($_.Group[5].Backup6)}
elseif ($_.Group[6].Backup6 -ne $null) {
($_.Group[6].Backup6)}
elseif ($_.Group[7].Backup6 -ne $null) {
($_.Group[7].Backup6)}
elseif ($_.Group[8].Backup6 -ne $null) {
($_.Group[8].Backup6)}
elseif ($_.Group[9].Backup6 -ne $null) {
($_.Group[9].Backup6)}
elseif ($_.Group[10].Backup6 -ne $null) {
($_.Group[10].Backup6)};
Backup7 = if ($_.Group[0].Backup7 -ne $null) {
($_.Group[0].Backup7)}
elseif ($_.Group[1].Backup7 -ne $null) {
($_.Group[1].Backup7)}
elseif ($_.Group[2].Backup7 -ne $null) {
($_.Group[2].Backup7)}
elseif ($_.Group[3].Backup7 -ne $null) {
($_.Group[3].Backup7)}
elseif ($_.Group[4].Backup7 -ne $null) {
($_.Group[4].Backup7)}
elseif ($_.Group[5].Backup7 -ne $null) {
($_.Group[5].Backup7)}
elseif ($_.Group[6].Backup7 -ne $null) {
($_.Group[6].Backup7)}
elseif ($_.Group[7].Backup7 -ne $null) {
($_.Group[7].Backup7)}
elseif ($_.Group[8].Backup7 -ne $null) {
($_.Group[8].Backup7)}
elseif ($_.Group[9].Backup7 -ne $null) {
($_.Group[9].Backup7)}
elseif ($_.Group[10].Backup7 -ne $null) {
($_.Group[10].Backup7)};
Backup8 = if ($_.Group[0].Backup8 -ne $null) {
($_.Group[0].Backup8)}
elseif ($_.Group[1].Backup8 -ne $null) {
($_.Group[1].Backup8)}
elseif ($_.Group[2].Backup8 -ne $null) {
($_.Group[2].Backup8)}
elseif ($_.Group[3].Backup8 -ne $null) {
($_.Group[3].Backup8)}
elseif ($_.Group[4].Backup8 -ne $null) {
($_.Group[4].Backup8)}
elseif ($_.Group[5].Backup8 -ne $null) {
($_.Group[5].Backup8)}
elseif ($_.Group[6].Backup8 -ne $null) {
($_.Group[6].Backup8)}
elseif ($_.Group[7].Backup8 -ne $null) {
($_.Group[7].Backup8)}
elseif ($_.Group[8].Backup8 -ne $null) {
($_.Group[8].Backup8)}
elseif ($_.Group[9].Backup8 -ne $null) {
($_.Group[9].Backup8)}
elseif ($_.Group[10].Backup8 -ne $null) {
($_.Group[10].Backup8)};
Backup9 = if ($_.Group[0].Backup9 -ne $null) {
($_.Group[0].Backup9)}
elseif ($_.Group[1].Backup9 -ne $null) {
($_.Group[1].Backup9)}
elseif ($_.Group[2].Backup9 -ne $null) {
($_.Group[2].Backup9)}
elseif ($_.Group[3].Backup9 -ne $null) {
($_.Group[3].Backup9)}
elseif ($_.Group[4].Backup9 -ne $null) {
($_.Group[4].Backup9)}
elseif ($_.Group[5].Backup9 -ne $null) {
($_.Group[5].Backup9)}
elseif ($_.Group[6].Backup9 -ne $null) {
($_.Group[6].Backup9)}
elseif ($_.Group[7].Backup9 -ne $null) {
($_.Group[7].Backup9)}
elseif ($_.Group[8].Backup9 -ne $null) {
($_.Group[8].Backup9)}
elseif ($_.Group[9].Backup9 -ne $null) {
($_.Group[9].Backup9)}
elseif ($_.Group[10].Backup9 -ne $null) {
($_.Group[10].Backup9)};
}
} | select Name,@{N="$Date2";E={$_.Backup2}},@{N="$Date3";E={$_.Backup3}},@{N="Weekend of $Date4";E={$_.Backup4}},@{N="$Date6";E={$_.Backup6}},@{N="$Date7";E={$_.Backup7}},@{N="$Date8";E={$_.Backup8}},@{N="$Date9";E={$_.Backup9}} | Sort Name | ConvertTo-Html -Fragment #| set-cellcolor -Property $Date1 -Color red -Filter "$Date1 -like 'Failed'" | set-cellcolor -Property $Date1 -Color '#00ff00' -Filter "$Date1 -like 'Success'" | set-cellcolor -Property $Date1 -Color '#FFFF00' -Filter "$Date1 -like 'Warning'"
} elseif ([DateTime]::Today.AddDays($Day4).DayOfWeek -eq "Sunday") {
Write-Host "Combined"
$bodySummaryRp = $EndResult | Group Name | ForEach {
New-Object PSObject -Property @{
Name = $_.Name

Backup2 = if ($_.Group[0].Backup2 -ne $null) {
($_.Group[0].Backup2)}
elseif ($_.Group[1].Backup2 -ne $null) {
($_.Group[1].Backup2)}
elseif ($_.Group[2].Backup2 -ne $null) {
($_.Group[2].Backup2)}
elseif ($_.Group[3].Backup2 -ne $null) {
($_.Group[3].Backup2)}
elseif ($_.Group[4].Backup2 -ne $null) {
($_.Group[4].Backup2)}
elseif ($_.Group[5].Backup2 -ne $null) {
($_.Group[5].Backup2)}
elseif ($_.Group[6].Backup2 -ne $null) {
($_.Group[6].Backup2)}
elseif ($_.Group[7].Backup2 -ne $null) {
($_.Group[7].Backup2)}
elseif ($_.Group[8].Backup2 -ne $null) {
($_.Group[8].Backup2)}
elseif ($_.Group[9].Backup2 -ne $null) {
($_.Group[9].Backup2)}
elseif ($_.Group[10].Backup2 -ne $null) {
($_.Group[10].Backup2)};
Backup3 = if ($_.Group[0].Backup3 -ne $null) {
($_.Group[0].Backup3)}
elseif ($_.Group[1].Backup3 -ne $null) {
($_.Group[1].Backup3)}
elseif ($_.Group[2].Backup3 -ne $null) {
($_.Group[2].Backup3)}
elseif ($_.Group[3].Backup3 -ne $null) {
($_.Group[3].Backup3)}
elseif ($_.Group[4].Backup3 -ne $null) {
($_.Group[4].Backup3)}
elseif ($_.Group[5].Backup3 -ne $null) {
($_.Group[5].Backup3)}
elseif ($_.Group[6].Backup3 -ne $null) {
($_.Group[6].Backup3)}
elseif ($_.Group[7].Backup3 -ne $null) {
($_.Group[7].Backup3)}
elseif ($_.Group[8].Backup3 -ne $null) {
($_.Group[8].Backup3)}
elseif ($_.Group[9].Backup3 -ne $null) {
($_.Group[9].Backup3)}
elseif ($_.Group[10].Backup3 -ne $null) {
($_.Group[10].Backup3)};
Backup4 = if ($_.Group[0].Backup4 -ne $null) {
($_.Group[0].Backup4)}
elseif ($_.Group[1].Backup4 -ne $null) {
($_.Group[1].Backup4)}
elseif ($_.Group[2].Backup4 -ne $null) {
($_.Group[2].Backup4)}
elseif ($_.Group[3].Backup4 -ne $null) {
($_.Group[3].Backup4)}
elseif ($_.Group[4].Backup4 -ne $null) {
($_.Group[4].Backup4)}
elseif ($_.Group[5].Backup4 -ne $null) {
($_.Group[5].Backup4)}
elseif ($_.Group[6].Backup4 -ne $null) {
($_.Group[6].Backup4)}
elseif ($_.Group[7].Backup4 -ne $null) {
($_.Group[7].Backup4)}
elseif ($_.Group[8].Backup4 -ne $null) {
($_.Group[8].Backup4)}
elseif ($_.Group[9].Backup4 -ne $null) {
($_.Group[9].Backup4)}
elseif ($_.Group[10].Backup4 -ne $null) {
($_.Group[10].Backup4)};
Backup5 = if ($_.Group[0].Backup5 -ne $null) {
($_.Group[0].Backup5)}
elseif ($_.Group[1].Backup5 -ne $null) {
($_.Group[1].Backup5)}
elseif ($_.Group[2].Backup5 -ne $null) {
($_.Group[2].Backup5)}
elseif ($_.Group[3].Backup5 -ne $null) {
($_.Group[3].Backup5)}
elseif ($_.Group[4].Backup5 -ne $null) {
($_.Group[4].Backup5)}
elseif ($_.Group[5].Backup5 -ne $null) {
($_.Group[5].Backup5)}
elseif ($_.Group[6].Backup5 -ne $null) {
($_.Group[6].Backup5)}
elseif ($_.Group[7].Backup5 -ne $null) {
($_.Group[7].Backup5)}
elseif ($_.Group[8].Backup5 -ne $null) {
($_.Group[8].Backup5)}
elseif ($_.Group[9].Backup5 -ne $null) {
($_.Group[9].Backup5)}
elseif ($_.Group[10].Backup5 -ne $null) {
($_.Group[10].Backup5)};

Backup7 = if ($_.Group[0].Backup7 -ne $null) {
($_.Group[0].Backup7)}
elseif ($_.Group[1].Backup7 -ne $null) {
($_.Group[1].Backup7)}
elseif ($_.Group[2].Backup7 -ne $null) {
($_.Group[2].Backup7)}
elseif ($_.Group[3].Backup7 -ne $null) {
($_.Group[3].Backup7)}
elseif ($_.Group[4].Backup7 -ne $null) {
($_.Group[4].Backup7)}
elseif ($_.Group[5].Backup7 -ne $null) {
($_.Group[5].Backup7)}
elseif ($_.Group[6].Backup7 -ne $null) {
($_.Group[6].Backup7)}
elseif ($_.Group[7].Backup7 -ne $null) {
($_.Group[7].Backup7)}
elseif ($_.Group[8].Backup7 -ne $null) {
($_.Group[8].Backup7)}
elseif ($_.Group[9].Backup7 -ne $null) {
($_.Group[9].Backup7)}
elseif ($_.Group[10].Backup7 -ne $null) {
($_.Group[10].Backup7)};
Backup8 = if ($_.Group[0].Backup8 -ne $null) {
($_.Group[0].Backup8)}
elseif ($_.Group[1].Backup8 -ne $null) {
($_.Group[1].Backup8)}
elseif ($_.Group[2].Backup8 -ne $null) {
($_.Group[2].Backup8)}
elseif ($_.Group[3].Backup8 -ne $null) {
($_.Group[3].Backup8)}
elseif ($_.Group[4].Backup8 -ne $null) {
($_.Group[4].Backup8)}
elseif ($_.Group[5].Backup8 -ne $null) {
($_.Group[5].Backup8)}
elseif ($_.Group[6].Backup8 -ne $null) {
($_.Group[6].Backup8)}
elseif ($_.Group[7].Backup8 -ne $null) {
($_.Group[7].Backup8)}
elseif ($_.Group[8].Backup8 -ne $null) {
($_.Group[8].Backup8)}
elseif ($_.Group[9].Backup8 -ne $null) {
($_.Group[9].Backup8)}
elseif ($_.Group[10].Backup8 -ne $null) {
($_.Group[10].Backup8)};
Backup9 = if ($_.Group[0].Backup9 -ne $null) {
($_.Group[0].Backup9)}
elseif ($_.Group[1].Backup9 -ne $null) {
($_.Group[1].Backup9)}
elseif ($_.Group[2].Backup9 -ne $null) {
($_.Group[2].Backup9)}
elseif ($_.Group[3].Backup9 -ne $null) {
($_.Group[3].Backup9)}
elseif ($_.Group[4].Backup9 -ne $null) {
($_.Group[4].Backup9)}
elseif ($_.Group[5].Backup9 -ne $null) {
($_.Group[5].Backup9)}
elseif ($_.Group[6].Backup9 -ne $null) {
($_.Group[6].Backup9)}
elseif ($_.Group[7].Backup9 -ne $null) {
($_.Group[7].Backup9)}
elseif ($_.Group[8].Backup9 -ne $null) {
($_.Group[8].Backup9)}
elseif ($_.Group[9].Backup9 -ne $null) {
($_.Group[9].Backup9)}
elseif ($_.Group[10].Backup9 -ne $null) {
($_.Group[10].Backup9)};
}
} | select Name,@{N="$Date2";E={$_.Backup2}},@{N="$Date3";E={$_.Backup3}},@{N="$Date4";E={$_.Backup4}},@{N="Weekend of $Date5";E={$_.Backup5}},@{N="$Date7";E={$_.Backup7}},@{N="$Date8";E={$_.Backup8}},@{N="$Date9";E={$_.Backup9}} | Sort Name | ConvertTo-Html -Fragment #| set-cellcolor -Property $Date1 -Color red -Filter "$Date1 -like 'Failed'" | set-cellcolor -Property $Date1 -Color '#00ff00' -Filter "$Date1 -like 'Success'" | set-cellcolor -Property $Date1 -Color '#FFFF00' -Filter "$Date1 -like 'Warning'"
} elseif ([DateTime]::Today.AddDays($Day3).DayOfWeek -eq "Sunday") {
Write-Host "Combined"
$bodySummaryRp = $EndResult | Group Name | ForEach {
New-Object PSObject -Property @{
Name = $_.Name

Backup2 = if ($_.Group[0].Backup2 -ne $null) {
($_.Group[0].Backup2)}
elseif ($_.Group[1].Backup2 -ne $null) {
($_.Group[1].Backup2)}
elseif ($_.Group[2].Backup2 -ne $null) {
($_.Group[2].Backup2)}
elseif ($_.Group[3].Backup2 -ne $null) {
($_.Group[3].Backup2)}
elseif ($_.Group[4].Backup2 -ne $null) {
($_.Group[4].Backup2)}
elseif ($_.Group[5].Backup2 -ne $null) {
($_.Group[5].Backup2)}
elseif ($_.Group[6].Backup2 -ne $null) {
($_.Group[6].Backup2)}
elseif ($_.Group[7].Backup2 -ne $null) {
($_.Group[7].Backup2)}
elseif ($_.Group[8].Backup2 -ne $null) {
($_.Group[8].Backup2)}
elseif ($_.Group[9].Backup2 -ne $null) {
($_.Group[9].Backup2)}
elseif ($_.Group[10].Backup2 -ne $null) {
($_.Group[10].Backup2)};
Backup3 = if ($_.Group[0].Backup3 -ne $null) {
($_.Group[0].Backup3)}
elseif ($_.Group[1].Backup3 -ne $null) {
($_.Group[1].Backup3)}
elseif ($_.Group[2].Backup3 -ne $null) {
($_.Group[2].Backup3)}
elseif ($_.Group[3].Backup3 -ne $null) {
($_.Group[3].Backup3)}
elseif ($_.Group[4].Backup3 -ne $null) {
($_.Group[4].Backup3)}
elseif ($_.Group[5].Backup3 -ne $null) {
($_.Group[5].Backup3)}
elseif ($_.Group[6].Backup3 -ne $null) {
($_.Group[6].Backup3)}
elseif ($_.Group[7].Backup3 -ne $null) {
($_.Group[7].Backup3)}
elseif ($_.Group[8].Backup3 -ne $null) {
($_.Group[8].Backup3)}
elseif ($_.Group[9].Backup3 -ne $null) {
($_.Group[9].Backup3)}
elseif ($_.Group[10].Backup3 -ne $null) {
($_.Group[10].Backup3)};
Backup4 = if ($_.Group[0].Backup4 -ne $null) {
($_.Group[0].Backup4)}
elseif ($_.Group[1].Backup4 -ne $null) {
($_.Group[1].Backup4)}
elseif ($_.Group[2].Backup4 -ne $null) {
($_.Group[2].Backup4)}
elseif ($_.Group[3].Backup4 -ne $null) {
($_.Group[3].Backup4)}
elseif ($_.Group[4].Backup4 -ne $null) {
($_.Group[4].Backup4)}
elseif ($_.Group[5].Backup4 -ne $null) {
($_.Group[5].Backup4)}
elseif ($_.Group[6].Backup4 -ne $null) {
($_.Group[6].Backup4)}
elseif ($_.Group[7].Backup4 -ne $null) {
($_.Group[7].Backup4)}
elseif ($_.Group[8].Backup4 -ne $null) {
($_.Group[8].Backup4)}
elseif ($_.Group[9].Backup4 -ne $null) {
($_.Group[9].Backup4)}
elseif ($_.Group[10].Backup4 -ne $null) {
($_.Group[10].Backup4)};
Backup5 = if ($_.Group[0].Backup5 -ne $null) {
($_.Group[0].Backup5)}
elseif ($_.Group[1].Backup5 -ne $null) {
($_.Group[1].Backup5)}
elseif ($_.Group[2].Backup5 -ne $null) {
($_.Group[2].Backup5)}
elseif ($_.Group[3].Backup5 -ne $null) {
($_.Group[3].Backup5)}
elseif ($_.Group[4].Backup5 -ne $null) {
($_.Group[4].Backup5)}
elseif ($_.Group[5].Backup5 -ne $null) {
($_.Group[5].Backup5)}
elseif ($_.Group[6].Backup5 -ne $null) {
($_.Group[6].Backup5)}
elseif ($_.Group[7].Backup5 -ne $null) {
($_.Group[7].Backup5)}
elseif ($_.Group[8].Backup5 -ne $null) {
($_.Group[8].Backup5)}
elseif ($_.Group[9].Backup5 -ne $null) {
($_.Group[9].Backup5)}
elseif ($_.Group[10].Backup5 -ne $null) {
($_.Group[10].Backup5)};
Backup6 = if ($_.Group[0].Backup6 -ne $null) {
($_.Group[0].Backup6)}
elseif ($_.Group[1].Backup6 -ne $null) {
($_.Group[1].Backup6)}
elseif ($_.Group[2].Backup6 -ne $null) {
($_.Group[2].Backup6)}
elseif ($_.Group[3].Backup6 -ne $null) {
($_.Group[3].Backup6)}
elseif ($_.Group[4].Backup6 -ne $null) {
($_.Group[4].Backup6)}
elseif ($_.Group[5].Backup6 -ne $null) {
($_.Group[5].Backup6)}
elseif ($_.Group[6].Backup6 -ne $null) {
($_.Group[6].Backup6)}
elseif ($_.Group[7].Backup6 -ne $null) {
($_.Group[7].Backup6)}
elseif ($_.Group[8].Backup6 -ne $null) {
($_.Group[8].Backup6)}
elseif ($_.Group[9].Backup6 -ne $null) {
($_.Group[9].Backup6)}
elseif ($_.Group[10].Backup6 -ne $null) {
($_.Group[10].Backup6)};
Backup8 = if ($_.Group[0].Backup8 -ne $null) {
($_.Group[0].Backup8)}
elseif ($_.Group[1].Backup8 -ne $null) {
($_.Group[1].Backup8)}
elseif ($_.Group[2].Backup8 -ne $null) {
($_.Group[2].Backup8)}
elseif ($_.Group[3].Backup8 -ne $null) {
($_.Group[3].Backup8)}
elseif ($_.Group[4].Backup8 -ne $null) {
($_.Group[4].Backup8)}
elseif ($_.Group[5].Backup8 -ne $null) {
($_.Group[5].Backup8)}
elseif ($_.Group[6].Backup8 -ne $null) {
($_.Group[6].Backup8)}
elseif ($_.Group[7].Backup8 -ne $null) {
($_.Group[7].Backup8)}
elseif ($_.Group[8].Backup8 -ne $null) {
($_.Group[8].Backup8)}
elseif ($_.Group[9].Backup8 -ne $null) {
($_.Group[9].Backup8)}
elseif ($_.Group[10].Backup8 -ne $null) {
($_.Group[10].Backup8)};
Backup9 = if ($_.Group[0].Backup9 -ne $null) {
($_.Group[0].Backup9)}
elseif ($_.Group[1].Backup9 -ne $null) {
($_.Group[1].Backup9)}
elseif ($_.Group[2].Backup9 -ne $null) {
($_.Group[2].Backup9)}
elseif ($_.Group[3].Backup9 -ne $null) {
($_.Group[3].Backup9)}
elseif ($_.Group[4].Backup9 -ne $null) {
($_.Group[4].Backup9)}
elseif ($_.Group[5].Backup9 -ne $null) {
($_.Group[5].Backup9)}
elseif ($_.Group[6].Backup9 -ne $null) {
($_.Group[6].Backup9)}
elseif ($_.Group[7].Backup9 -ne $null) {
($_.Group[7].Backup9)}
elseif ($_.Group[8].Backup9 -ne $null) {
($_.Group[8].Backup9)}
elseif ($_.Group[9].Backup9 -ne $null) {
($_.Group[9].Backup9)}
elseif ($_.Group[10].Backup9 -ne $null) {
($_.Group[10].Backup9)};
}
} | select Name,@{N="$Date2";E={$_.Backup2}},@{N="$Date3";E={$_.Backup3}},@{N="$Date4";E={$_.Backup4}},@{N="$Date5";E={$_.Backup5}},@{N="Weekend of $Date6";E={$_.Backup6}},@{N="$Date8";E={$_.Backup8}},@{N="$Date9";E={$_.Backup9}} | Sort Name | ConvertTo-Html -Fragment #| set-cellcolor -Property $Date1 -Color red -Filter "$Date1 -like 'Failed'" | set-cellcolor -Property $Date1 -Color '#00ff00' -Filter "$Date1 -like 'Success'" | set-cellcolor -Property $Date1 -Color '#FFFF00' -Filter "$Date1 -like 'Warning'"
} elseif ([DateTime]::Today.AddDays($Day2).DayOfWeek -eq "Sunday") {
Write-Host "Combined"
$bodySummaryRp = $EndResult | Group Name | ForEach {
New-Object PSObject -Property @{
Name = $_.Name

Backup2 = if ($_.Group[0].Backup2 -ne $null) {
($_.Group[0].Backup2)}
elseif ($_.Group[1].Backup2 -ne $null) {
($_.Group[1].Backup2)}
elseif ($_.Group[2].Backup2 -ne $null) {
($_.Group[2].Backup2)}
elseif ($_.Group[3].Backup2 -ne $null) {
($_.Group[3].Backup2)}
elseif ($_.Group[4].Backup2 -ne $null) {
($_.Group[4].Backup2)}
elseif ($_.Group[5].Backup2 -ne $null) {
($_.Group[5].Backup2)}
elseif ($_.Group[6].Backup2 -ne $null) {
($_.Group[6].Backup2)}
elseif ($_.Group[7].Backup2 -ne $null) {
($_.Group[7].Backup2)}
elseif ($_.Group[8].Backup2 -ne $null) {
($_.Group[8].Backup2)}
elseif ($_.Group[9].Backup2 -ne $null) {
($_.Group[9].Backup2)}
elseif ($_.Group[10].Backup2 -ne $null) {
($_.Group[10].Backup2)};
Backup3 = if ($_.Group[0].Backup3 -ne $null) {
($_.Group[0].Backup3)}
elseif ($_.Group[1].Backup3 -ne $null) {
($_.Group[1].Backup3)}
elseif ($_.Group[2].Backup3 -ne $null) {
($_.Group[2].Backup3)}
elseif ($_.Group[3].Backup3 -ne $null) {
($_.Group[3].Backup3)}
elseif ($_.Group[4].Backup3 -ne $null) {
($_.Group[4].Backup3)}
elseif ($_.Group[5].Backup3 -ne $null) {
($_.Group[5].Backup3)}
elseif ($_.Group[6].Backup3 -ne $null) {
($_.Group[6].Backup3)}
elseif ($_.Group[7].Backup3 -ne $null) {
($_.Group[7].Backup3)}
elseif ($_.Group[8].Backup3 -ne $null) {
($_.Group[8].Backup3)}
elseif ($_.Group[9].Backup3 -ne $null) {
($_.Group[9].Backup3)}
elseif ($_.Group[10].Backup3 -ne $null) {
($_.Group[10].Backup3)};
Backup4 = if ($_.Group[0].Backup4 -ne $null) {
($_.Group[0].Backup4)}
elseif ($_.Group[1].Backup4 -ne $null) {
($_.Group[1].Backup4)}
elseif ($_.Group[2].Backup4 -ne $null) {
($_.Group[2].Backup4)}
elseif ($_.Group[3].Backup4 -ne $null) {
($_.Group[3].Backup4)}
elseif ($_.Group[4].Backup4 -ne $null) {
($_.Group[4].Backup4)}
elseif ($_.Group[5].Backup4 -ne $null) {
($_.Group[5].Backup4)}
elseif ($_.Group[6].Backup4 -ne $null) {
($_.Group[6].Backup4)}
elseif ($_.Group[7].Backup4 -ne $null) {
($_.Group[7].Backup4)}
elseif ($_.Group[8].Backup4 -ne $null) {
($_.Group[8].Backup4)}
elseif ($_.Group[9].Backup4 -ne $null) {
($_.Group[9].Backup4)}
elseif ($_.Group[10].Backup4 -ne $null) {
($_.Group[10].Backup4)};
Backup5 = if ($_.Group[0].Backup5 -ne $null) {
($_.Group[0].Backup5)}
elseif ($_.Group[1].Backup5 -ne $null) {
($_.Group[1].Backup5)}
elseif ($_.Group[2].Backup5 -ne $null) {
($_.Group[2].Backup5)}
elseif ($_.Group[3].Backup5 -ne $null) {
($_.Group[3].Backup5)}
elseif ($_.Group[4].Backup5 -ne $null) {
($_.Group[4].Backup5)}
elseif ($_.Group[5].Backup5 -ne $null) {
($_.Group[5].Backup5)}
elseif ($_.Group[6].Backup5 -ne $null) {
($_.Group[6].Backup5)}
elseif ($_.Group[7].Backup5 -ne $null) {
($_.Group[7].Backup5)}
elseif ($_.Group[8].Backup5 -ne $null) {
($_.Group[8].Backup5)}
elseif ($_.Group[9].Backup5 -ne $null) {
($_.Group[9].Backup5)}
elseif ($_.Group[10].Backup5 -ne $null) {
($_.Group[10].Backup5)};
Backup6 = if ($_.Group[0].Backup6 -ne $null) {
($_.Group[0].Backup6)}
elseif ($_.Group[1].Backup6 -ne $null) {
($_.Group[1].Backup6)}
elseif ($_.Group[2].Backup6 -ne $null) {
($_.Group[2].Backup6)}
elseif ($_.Group[3].Backup6 -ne $null) {
($_.Group[3].Backup6)}
elseif ($_.Group[4].Backup6 -ne $null) {
($_.Group[4].Backup6)}
elseif ($_.Group[5].Backup6 -ne $null) {
($_.Group[5].Backup6)}
elseif ($_.Group[6].Backup6 -ne $null) {
($_.Group[6].Backup6)}
elseif ($_.Group[7].Backup6 -ne $null) {
($_.Group[7].Backup6)}
elseif ($_.Group[8].Backup6 -ne $null) {
($_.Group[8].Backup6)}
elseif ($_.Group[9].Backup6 -ne $null) {
($_.Group[9].Backup6)}
elseif ($_.Group[10].Backup6 -ne $null) {
($_.Group[10].Backup6)};
Backup7 = if ($_.Group[0].Backup7 -ne $null) {
($_.Group[0].Backup7)}
elseif ($_.Group[1].Backup7 -ne $null) {
($_.Group[1].Backup7)}
elseif ($_.Group[2].Backup7 -ne $null) {
($_.Group[2].Backup7)}
elseif ($_.Group[3].Backup7 -ne $null) {
($_.Group[3].Backup7)}
elseif ($_.Group[4].Backup7 -ne $null) {
($_.Group[4].Backup7)}
elseif ($_.Group[5].Backup7 -ne $null) {
($_.Group[5].Backup7)}
elseif ($_.Group[6].Backup7 -ne $null) {
($_.Group[6].Backup7)}
elseif ($_.Group[7].Backup7 -ne $null) {
($_.Group[7].Backup7)}
elseif ($_.Group[8].Backup7 -ne $null) {
($_.Group[8].Backup7)}
elseif ($_.Group[9].Backup7 -ne $null) {
($_.Group[9].Backup7)}
elseif ($_.Group[10].Backup7 -ne $null) {
($_.Group[10].Backup7)};
Backup9 = if ($_.Group[0].Backup9 -ne $null) {
($_.Group[0].Backup9)}
elseif ($_.Group[1].Backup9 -ne $null) {
($_.Group[1].Backup9)}
elseif ($_.Group[2].Backup9 -ne $null) {
($_.Group[2].Backup9)}
elseif ($_.Group[3].Backup9 -ne $null) {
($_.Group[3].Backup9)}
elseif ($_.Group[4].Backup9 -ne $null) {
($_.Group[4].Backup9)}
elseif ($_.Group[5].Backup9 -ne $null) {
($_.Group[5].Backup9)}
elseif ($_.Group[6].Backup9 -ne $null) {
($_.Group[6].Backup9)}
elseif ($_.Group[7].Backup9 -ne $null) {
($_.Group[7].Backup9)}
elseif ($_.Group[8].Backup9 -ne $null) {
($_.Group[8].Backup9)}
elseif ($_.Group[9].Backup9 -ne $null) {
($_.Group[9].Backup9)}
elseif ($_.Group[10].Backup9 -ne $null) {
($_.Group[10].Backup9)};
}
} | select Name,@{N="$Date2";E={$_.Backup2}},@{N="$Date3";E={$_.Backup3}},@{N="$Date4";E={$_.Backup4}},@{N="$Date5";E={$_.Backup5}},@{N="$Date6";E={$_.Backup6}},@{N="Weekend of $Date7";E={$_.Backup7}},@{N="$Date9";E={$_.Backup9}} | Sort Name | ConvertTo-Html -Fragment #| set-cellcolor -Property $Date1 -Color red -Filter "$Date1 -like 'Failed'" | set-cellcolor -Property $Date1 -Color '#00ff00' -Filter "$Date1 -like 'Success'" | set-cellcolor -Property $Date1 -Color '#FFFF00' -Filter "$Date1 -like 'Warning'"
} elseif ([DateTime]::Today.AddDays($Day1).DayOfWeek -eq "Sunday") {
Write-Host "Combined"
$bodySummaryRp = $EndResult | Group Name | ForEach {
New-Object PSObject -Property @{
Name = $_.Name
Backup1 = if ($_.Group[0].Backup1 -ne $null) {
($_.Group[0].Backup1)}
elseif ($_.Group[1].Backup1 -ne $null) {
($_.Group[1].Backup1)}
elseif ($_.Group[2].Backup1 -ne $null) {
($_.Group[2].Backup1)}
elseif ($_.Group[3].Backup1 -ne $null) {
($_.Group[3].Backup1)}
elseif ($_.Group[4].Backup1 -ne $null) {
($_.Group[4].Backup1)}
elseif ($_.Group[5].Backup1 -ne $null) {
($_.Group[5].Backup1)}
elseif ($_.Group[6].Backup1 -ne $null) {
($_.Group[6].Backup1)}
elseif ($_.Group[7].Backup1 -ne $null) {
($_.Group[7].Backup1)}
elseif ($_.Group[8].Backup1 -ne $null) {
($_.Group[8].Backup1)}
elseif ($_.Group[9].Backup1 -ne $null) {
($_.Group[9].Backup1)}
elseif ($_.Group[10].Backup1 -ne $null) {
($_.Group[10].Backup1)};

Backup3 = if ($_.Group[0].Backup3 -ne $null) {
($_.Group[0].Backup3)}
elseif ($_.Group[1].Backup3 -ne $null) {
($_.Group[1].Backup3)}
elseif ($_.Group[2].Backup3 -ne $null) {
($_.Group[2].Backup3)}
elseif ($_.Group[3].Backup3 -ne $null) {
($_.Group[3].Backup3)}
elseif ($_.Group[4].Backup3 -ne $null) {
($_.Group[4].Backup3)}
elseif ($_.Group[5].Backup3 -ne $null) {
($_.Group[5].Backup3)}
elseif ($_.Group[6].Backup3 -ne $null) {
($_.Group[6].Backup3)}
elseif ($_.Group[7].Backup3 -ne $null) {
($_.Group[7].Backup3)}
elseif ($_.Group[8].Backup3 -ne $null) {
($_.Group[8].Backup3)}
elseif ($_.Group[9].Backup3 -ne $null) {
($_.Group[9].Backup3)}
elseif ($_.Group[10].Backup3 -ne $null) {
($_.Group[10].Backup3)};
Backup4 = if ($_.Group[0].Backup4 -ne $null) {
($_.Group[0].Backup4)}
elseif ($_.Group[1].Backup4 -ne $null) {
($_.Group[1].Backup4)}
elseif ($_.Group[2].Backup4 -ne $null) {
($_.Group[2].Backup4)}
elseif ($_.Group[3].Backup4 -ne $null) {
($_.Group[3].Backup4)}
elseif ($_.Group[4].Backup4 -ne $null) {
($_.Group[4].Backup4)}
elseif ($_.Group[5].Backup4 -ne $null) {
($_.Group[5].Backup4)}
elseif ($_.Group[6].Backup4 -ne $null) {
($_.Group[6].Backup4)}
elseif ($_.Group[7].Backup4 -ne $null) {
($_.Group[7].Backup4)}
elseif ($_.Group[8].Backup4 -ne $null) {
($_.Group[8].Backup4)}
elseif ($_.Group[9].Backup4 -ne $null) {
($_.Group[9].Backup4)}
elseif ($_.Group[10].Backup4 -ne $null) {
($_.Group[10].Backup4)};
Backup5 = if ($_.Group[0].Backup5 -ne $null) {
($_.Group[0].Backup5)}
elseif ($_.Group[1].Backup5 -ne $null) {
($_.Group[1].Backup5)}
elseif ($_.Group[2].Backup5 -ne $null) {
($_.Group[2].Backup5)}
elseif ($_.Group[3].Backup5 -ne $null) {
($_.Group[3].Backup5)}
elseif ($_.Group[4].Backup5 -ne $null) {
($_.Group[4].Backup5)}
elseif ($_.Group[5].Backup5 -ne $null) {
($_.Group[5].Backup5)}
elseif ($_.Group[6].Backup5 -ne $null) {
($_.Group[6].Backup5)}
elseif ($_.Group[7].Backup5 -ne $null) {
($_.Group[7].Backup5)}
elseif ($_.Group[8].Backup5 -ne $null) {
($_.Group[8].Backup5)}
elseif ($_.Group[9].Backup5 -ne $null) {
($_.Group[9].Backup5)}
elseif ($_.Group[10].Backup5 -ne $null) {
($_.Group[10].Backup5)};
Backup6 = if ($_.Group[0].Backup6 -ne $null) {
($_.Group[0].Backup6)}
elseif ($_.Group[1].Backup6 -ne $null) {
($_.Group[1].Backup6)}
elseif ($_.Group[2].Backup6 -ne $null) {
($_.Group[2].Backup6)}
elseif ($_.Group[3].Backup6 -ne $null) {
($_.Group[3].Backup6)}
elseif ($_.Group[4].Backup6 -ne $null) {
($_.Group[4].Backup6)}
elseif ($_.Group[5].Backup6 -ne $null) {
($_.Group[5].Backup6)}
elseif ($_.Group[6].Backup6 -ne $null) {
($_.Group[6].Backup6)}
elseif ($_.Group[7].Backup6 -ne $null) {
($_.Group[7].Backup6)}
elseif ($_.Group[8].Backup6 -ne $null) {
($_.Group[8].Backup6)}
elseif ($_.Group[9].Backup6 -ne $null) {
($_.Group[9].Backup6)}
elseif ($_.Group[10].Backup6 -ne $null) {
($_.Group[10].Backup6)};
Backup7 = if ($_.Group[0].Backup7 -ne $null) {
($_.Group[0].Backup7)}
elseif ($_.Group[1].Backup7 -ne $null) {
($_.Group[1].Backup7)}
elseif ($_.Group[2].Backup7 -ne $null) {
($_.Group[2].Backup7)}
elseif ($_.Group[3].Backup7 -ne $null) {
($_.Group[3].Backup7)}
elseif ($_.Group[4].Backup7 -ne $null) {
($_.Group[4].Backup7)}
elseif ($_.Group[5].Backup7 -ne $null) {
($_.Group[5].Backup7)}
elseif ($_.Group[6].Backup7 -ne $null) {
($_.Group[6].Backup7)}
elseif ($_.Group[7].Backup7 -ne $null) {
($_.Group[7].Backup7)}
elseif ($_.Group[8].Backup7 -ne $null) {
($_.Group[8].Backup7)}
elseif ($_.Group[9].Backup7 -ne $null) {
($_.Group[9].Backup7)}
elseif ($_.Group[10].Backup7 -ne $null) {
($_.Group[10].Backup7)};
Backup8 = if ($_.Group[0].Backup8 -ne $null) {
($_.Group[0].Backup8)}
elseif ($_.Group[1].Backup8 -ne $null) {
($_.Group[1].Backup8)}
elseif ($_.Group[2].Backup8 -ne $null) {
($_.Group[2].Backup8)}
elseif ($_.Group[3].Backup8 -ne $null) {
($_.Group[3].Backup8)}
elseif ($_.Group[4].Backup8 -ne $null) {
($_.Group[4].Backup8)}
elseif ($_.Group[5].Backup8 -ne $null) {
($_.Group[5].Backup8)}
elseif ($_.Group[6].Backup8 -ne $null) {
($_.Group[6].Backup8)}
elseif ($_.Group[7].Backup8 -ne $null) {
($_.Group[7].Backup8)}
elseif ($_.Group[8].Backup8 -ne $null) {
($_.Group[8].Backup8)}
elseif ($_.Group[9].Backup8 -ne $null) {
($_.Group[9].Backup8)}
elseif ($_.Group[10].Backup8 -ne $null) {
($_.Group[10].Backup8)};
}
} | select Name,@{N="Weekend of $Date1";E={$_.Backup1}},@{N="$Date3";E={$_.Backup3}},@{N="$Date4";E={$_.Backup4}},@{N="$Date5";E={$_.Backup5}},@{N="$Date6";E={$_.Backup6}},@{N="$Date7";E={$_.Backup7}},@{N="Weekend of $Date8";E={$_.Backup8}} | Sort Name | ConvertTo-Html -Fragment #| set-cellcolor -Property $Date1 -Color red -Filter "$Date1 -like 'Failed'" | set-cellcolor -Property $Date1 -Color '#00ff00' -Filter "$Date1 -like 'Success'" | set-cellcolor -Property $Date1 -Color '#FFFF00' -Filter "$Date1 -like 'Warning'"
}

#Compile all of the fragments together ready for the report
$htmlOutput = $headerObj + $bodyTop + $BodySummHeader + $bodySummaryRp 

$htmlOutput = $htmlOutput.Replace("$($HTMLbreak + $footerObj)","$($footerObj)")
# Add color to output depending on results
#Green
$htmlOutput = $htmlOutput.Replace("<td>Running<","<td style=""color: #00b051;"">Running<")
$htmlOutput = $htmlOutput.Replace("<td>OK<","<td style=""color: #00b051;"">OK<")
$htmlOutput = $htmlOutput.Replace("<td>Alive<","<td style=""color: #00b051;"">Alive<")
$htmlOutput = $htmlOutput.Replace("<td>Success<","<td style=""background-color: #00b051;color: #ffffff;text-align: center;"">Success<")
#Yellow
$htmlOutput = $htmlOutput.Replace("<td>Warning<","<td style=""background-color: #ffc000;text-align: center;"">Warning<")
#Red
$htmlOutput = $htmlOutput.Replace("<td>Not Running<","<td style=""color: #ff0000;"">Not Running<")
$htmlOutput = $htmlOutput.Replace("<td>Failed<","<td style=""background-color: #ff0000;color: #ffffff;text-align: center;"">Failed<")
$htmlOutput = $htmlOutput.Replace("<td>Critical<","<td style=""color: #ff0000;"">Critical<")
$htmlOutput = $htmlOutput.Replace("<td>Dead<","<td style=""color: #ff0000;"">Dead<")

#Save the report
$htmlOutput | Out-File $Outputlocation

#Email the report
$Email = $htmlOutput

$smtpServer = $smtpServerref
[string[]]$to = $emailTo
$from = $emailFrom
$subject = "Veeam Backup Report - $DateToday"
$body = ""
$body += $Email

Send-MailMessage -SmtpServer $smtpServer -To $to -From $from -Subject $subject -Body $body -BodyAsHtml

Blog-a-Week 2018 Posting (BAW):

In previous years, I have had periods throughout the year where I have been unable to post an entry to myblog.  During 2018, my aim is to post a blog entry each week of the year.  I’m hoping that the blog entries will all be useful bits of information or items that I’ve been working on recently but if the standard of the entries drops, I apologise now, as this could have been a busy week and I wasn’t able to put in as much time as I would have liked into the post

About the Author

Dinger

I'm a technical person who has held many IT related jobs for the past 20+ years. I am now working for VMware helping customers to maximise their investment in VMware technologies.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.