Found a pice of code that
did.. And it's what I'm loking for but... abit more.. I need to include this into my old script, This is we did a change in the v-center and created folders where we put in all the vm's and in veeam the same thing take backup of that folder...tsightler
just to make things a bit simpler for us..
but then I can't use the old script that I have to get the average and so on from the backups, and the code from tsightler.. might do the trick, but I need the help to understand where to add it..
Here is his script part:
Code: Select all
$jobname = "weekly-production-noAAP"
$vmsandtemplates = Find-VBRViEntity -VMsAndTemplates
$vmfoldertree = $vmsandtemplates |? {$_.Type -eq "Vm"}
$vmfolders = $vmsandtemplates |? {$_.Type -eq "Folder"}
$job = Get-VBRJob -Name $jobname | Sort -Property Name
$jobobjs = $job.GetObjectsInJob() | ?{$_.Type -eq "Include"}
$jobobjid = $jobobjs.GetObject().Info.HostId.ToString() + "_" + $jobobjs.GetObject().Info.ObjectId
$jobobjpath = ($vmfolders | ?{$_.Id -eq "$jobobjid"}).Path
write-host $jobobjpath
$vmsinfolder= $vmfoldertree |?{$_.Path -like "$jobobjpath*"} | Sort -Property Name
ForEach ($vm in $vmsinfolder) {
write-host " " $vm.Name
}
Code: Select all
$style = @"
<style>
TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}
TH{border-width: 1px;padding: 2px;border-style: solid;border-color: black;background-color:orange}
TD{border-width: 1px;padding: 2px;border-style: solid;border-color: black;background-color:lightblue}
tr.special {background: #000080;} <tr class="special"></tr>
</style>
"@
Add-PSSnapin VeeamPSSnapIn
$Report = @()
$Jobs = Get-VBRJob | ?{$_.Name -match ""}
foreach ($job in $Jobs) {
$jobName = $job.Name
$table = New-Object system.Data.DataTable "$table01"
$col1 = New-Object system.Data.DataColumn Index,([int])
$col2 = New-Object system.Data.DataColumn JobName,([string])
$col3 = New-Object system.Data.DataColumn StartTime,([DateTime])
$col4 = New-Object system.Data.DataColumn StopTime,([DateTime])
$col5 = New-Object system.Data.DataColumn FileName,([string])
$col6 = New-Object system.Data.DataColumn CreationTime,([DateTime])
$col7 = New-Object system.Data.DataColumn AvgSpeedMB,([int])
$col8 = New-Object system.Data.DataColumn Duration,([TimeSpan])
$col9 = New-Object system.Data.DataColumn Result,([String])
$table.columns.add($col1)
$table.columns.add($col2)
$table.columns.add($col3)
$table.columns.add($col4)
$table.columns.add($col5)
$table.columns.add($col6)
$table.columns.add($col7)
$table.columns.add($col8)
$table.columns.add($col9)
$session = Get-VBRBackupSession | ?{$_.JobId -eq $job.Id} | %{
$row = $table.NewRow()
$row.JobName = $_.JobName
$row.StartTime = $_.CreationTime
$row.StopTime = $_.EndTime
#Work out average speed in MB and round this to 0 decimal places, just like the Veeam GUI does.
$row.AvgSpeedMB = [Math]::Round($_.Progress.AvgSpeed/1024/1024,0)
$row.Duration = '{0:00}:{1:00}:{2:00}' -f $_.Progress.Duration.Hours, $_.Progress.Duration.Minutes, $_.Progress.Duration.Seconds
if ($_.Result -eq "Failed") {
#This is highlight is going to later be searched and replaced with HTML code to highlight failed jobs in RED :)
$row.Result = "#HIGHLIGHTRED"+$_.Result+"HIGHLIGHTRED#"
} else {
$row.Result = $_.Result
}
#Add this calculated row to the $table.Rows
$table.Rows.Add($row)
}
# $interestingsess = $table | Sort StartTime -descending | select -first 4
$interestingsess = $table | Where { ($_.StartTime) -gt (Get-Date 2014-08-10)} | Sort StartTime
$interestingsess
$pkc = 1
#if ($interestingsess -ne $Null){
# Write-Output "KpyTo!"
$interestingsess | foreach {
$_.Index = $pkc
#Increment $pkc, so the next foreach loop assigns a higher value to the next .Index property on the next row.
$pkc+=1
}
$backup = Get-VBRBackup | ?{$_.JobId -eq $job.Id}
#$points = $backup.GetStorages() | sort CreationTime -descending | Select -First 4
$points = $backup.GetStorages() | sort CreationTime -descending | Where-Object {$_.CreationTime -gt "2014-08-10"}
$ic = 1
ForEach ($point in $points) {
$rows = $table | ?{$_.Index -eq $ic}
#inner ForEach loop to assign the value of the backup point's filename to the row's .FileName property as well as the creation time.
ForEach ($row in $rows) {
($row.FileName = $point.FileName) -and ($row.CreationTime = $point.CreationTime)
#Increment the $ic variable ( +1 )
$ic+=1
}
}
#Tally up the current results into our $Report Array (add them)
$Report += $interestingsess
}
#Now we select those values of interest to us and convert the lot into HTML, assigning the styling we defined at the beginning of this script too.
$Report = $Report | Select Index, JobName, StartTime, StopTime, FileName, CreationTime, AvgSpeedMB, Duration, Result | ConvertTo-HTML -head $style
#Interesting bit - replace the highlighted parts with HTML code to flag up Failed jobs.
$Report = $Report -replace "#HIGHLIGHTRED","<font color='red'><B>"
$Report = $Report -replace "HIGHLIGHTRED#","</font></B>"
#Finally, save the report to a file on your drive.
$Report | Set-Content C:\Veeam-Backup.htm