{"id":4672,"date":"2020-05-21T05:06:18","date_gmt":"2020-05-21T05:06:18","guid":{"rendered":"https:\/\/pariswells.com\/blog\/?p=4672"},"modified":"2022-12-02T03:19:38","modified_gmt":"2022-12-02T03:19:38","slug":"calculating-previous-job-rate-of-change-as-well-as-averaging-history-in-powershell","status":"publish","type":"post","link":"https:\/\/pariswells.com\/blog\/research\/calculating-previous-job-rate-of-change-as-well-as-averaging-history-in-powershell","title":{"rendered":"Calculating Veam Previous Job Rate of Change as well as Averaging History in Powershell"},"content":{"rendered":"\n<p>Report % Rate of change from the last Backup Job Run<\/p>\n\n\n<div class=\"wp-block-wab-pastacode\">\n\t<div class=\"code-embed-wrapper\"> <pre class=\"language-markup code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-markup code-embed-code\">Add-PSSnapin -Name VeeamPSSnapIn -ErrorAction SilentlyContinue<br\/><br\/>Disconnect-VBRServer | out-null<br\/><br\/>connect-vbrserver -server localhost<br\/><br\/>$JobsOutput = @()<br\/><br\/>Foreach ($JobObject in Get-VBRJob | ?{$_.JobType -eq &quot;Backup&quot;})<br\/><br\/>{<br\/><br\/>$LastSession = $JobObject.FindLastSession()<br\/><br\/>$ChangeRate = ($LastSession.Info.Progress.TransferedSize\/$LastSession.Info.Progress.TotalUsedSize)*100<br\/><br\/>$JobOutput = New-Object -TypeName PSObject<br\/><br\/>$JobOutput | Add-Member -Name &quot;Jobname&quot; -MemberType Noteproperty -Value $JobObject.Name<br\/><br\/>$JobOutput | Add-Member -Name &quot;Endtime&quot; -MemberType Noteproperty -Value $LastSession.endtime<br\/><br\/>$JobOutput | Add-Member -Name &quot;TotalUsedSize&quot; -MemberType Noteproperty -Value $LastSession.Info.Progress.TotalUsedSize<br\/><br\/>$JobOutput | Add-Member -Name &quot;ReadSize&quot; -MemberType Noteproperty -Value $LastSession.Info.Progress.ReadSize<br\/><br\/>$JobOutput | Add-Member -Name &quot;TransferedSize&quot; -MemberType Noteproperty -Value $LastSession.Info.Progress.TransferedSize<br\/><br\/>$JobOutput | Add-Member -Name &quot;ChangeRate&quot; -MemberType Noteproperty -Value $ChangeRate<br\/><br\/>$JobsOutput += $JobOutput<br\/><br\/>}<br\/><br\/>$JobsOutput | Out-GridView<br\/><br\/>Disconnect-VBRServer | out-null<\/code><\/pre> <div class=\"code-embed-infos\"> <\/div> <\/div><\/div>\n\n\n\n<p>However one result is not a fair estimate of rate of change , and I don\u2019t have a Veeam One license so I decided to Average Stuff<\/p>\n\n\n\n<p>You can run on One VM or all the VM\u2019s in a Backup Job<\/p>\n\n\n<div class=\"wp-block-wab-pastacode\">\n\t<div class=\"code-embed-wrapper\"> <pre class=\"language-markup code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-markup code-embed-code\">Add-PSSnapin -Name VeeamPSSnapIn -ErrorAction SilentlyContinue<br\/><br\/>connect-vbrserver -server localhost<br\/><br\/>#Query to get all jobs in the time period in hours that have processed data (Data ne 0 ) and have completed<br\/><br\/>$vbrtasksessions = (Get-VBRBackupSession |<br\/><br\/>Where-Object {($_.EndTime -ge (Get-Date).addhours(-168) -or $_.CreationTime -ge (Get-Date).AddHours(-168) -or $_.State -eq &quot;Working&quot;)}) | Get-VBRTaskSession | Where-Object {$_.Status -notmatch &quot;Idle|InProgress|Pending|Fail&quot;-and $_.Info.Progress.TotalSize -ne &quot;0&quot;}<br\/><br\/>#Get Backup Job and VM<br\/><br\/>#$getOne = $vbrtasksessions | ? {$_.JobName -eq &quot;%Veeam Backup or Backup Copy Name%&quot; -and $_.Name -eq &quot;%Name of Server%&quot;}<br\/><br\/>#Or Get Whole Backup Job and average between all the machines<br\/><br\/>#$getOne = $vbrtasksessions | ? {$_.JobName -eq &quot;%Veeam Backup or Backup Copy Name%&quot;}<br\/><br\/>#Cannot Get Total usedSize in Backup<br\/><br\/>Echo ListofAllFullSizesInBytes $getOne.Info.Progress.TotalSize<br\/><br\/>#Echo AverageTotalFullBackupSizeInGB $([Math]::Round([Decimal]($getOne.Info.Progress.TotalSize | Measure-Object -Average).Average\/1GB, 2))<br\/><br\/>Echo ListofIntcrementalSizeinBytess $getOne.Info.Progress.TransferedSize<br\/><br\/>#Echo AverageIntSizeinGB $([Math]::Round([Decimal]($getOne.Info.Progress.TransferedSize | Measure-Object -Average).Average\/1GB, 2))<br\/><br\/>Echo RateofChangein% ((($getOne.Info.Progress.TransferedSize | Measure-Object -Average).Average\/($getOne.Info.Progress.TotalSize | Measure-Object -Average).Average)*100)<br\/><br\/>Disconnect-VBRServer | out-null<\/code><\/pre> <div class=\"code-embed-infos\"> <\/div> <\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Report % Rate of change from the last Backup Job Run However one result is not a fair estimate of rate of change , and I don\u2019t [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[3274,1120,576,3273,739],"class_list":["post-4672","post","type-post","status-publish","format-standard","hentry","category-research","tag-caculate","tag-history","tag-powershell","tag-rate-of-change","tag-veeam"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts\/4672","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/comments?post=4672"}],"version-history":[{"count":3,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts\/4672\/revisions"}],"predecessor-version":[{"id":6466,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts\/4672\/revisions\/6466"}],"wp:attachment":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/media?parent=4672"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/categories?post=4672"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/tags?post=4672"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}