PowerShell script exchange
Post Reply
pariswells
Lurker
Posts: 1
Liked: 2 times
Joined: May 21, 2020 4:43 am
Full Name: Paris Well
Contact:

Caculate Rate of Change ( Previous and History ) via Powershell

Post by pariswells » May 21, 2020 4:54 am 2 people like this post

So I modified an existing script to report on the % Rate of change from the last Backup Job Run

Code: Select all

Add-PSSnapin -Name VeeamPSSnapIn -ErrorAction SilentlyContinue

Disconnect-VBRServer | out-null
connect-vbrserver -server localhost

$JobsOutput = @()


Foreach ($JobObject in Get-VBRJob | ?{$_.JobType -eq "Backup"})
{


$LastSession = $JobObject.FindLastSession()
$ChangeRate = ($LastSession.Info.Progress.TransferedSize/$LastSession.Info.Progress.TotalUsedSize)*100
$JobOutput = New-Object -TypeName PSObject
$JobOutput | Add-Member -Name "Jobname" -MemberType Noteproperty -Value $JobObject.Name
$JobOutput | Add-Member -Name "Endtime" -MemberType Noteproperty -Value $LastSession.endtime
$JobOutput | Add-Member -Name "TotalUsedSize" -MemberType Noteproperty -Value $LastSession.Info.Progress.TotalUsedSize
$JobOutput | Add-Member -Name "ReadSize" -MemberType Noteproperty -Value $LastSession.Info.Progress.ReadSize
$JobOutput | Add-Member -Name "TransferedSize" -MemberType Noteproperty -Value $LastSession.Info.Progress.TransferedSize
$JobOutput | Add-Member -Name "ChangeRate" -MemberType Noteproperty -Value $ChangeRate
$JobsOutput += $JobOutput



}
$JobsOutput | Out-GridView
Disconnect-VBRServer | out-null
However one result is not a fair estimate of rate of change , and I don't have a Veeam One license so I decided to Average Stuff

You can run on One VM or all the VM's in a Backup Job

It def needs a tidy up but gets the job done , welcome to feedback

Code: Select all

Add-PSSnapin -Name VeeamPSSnapIn -ErrorAction SilentlyContinue
connect-vbrserver -server localhost
#Query to get all jobs in the time period in hours that have processed data (Data ne 0 ) and have completed
$vbrtasksessions = (Get-VBRBackupSession | 
Where-Object {($_.EndTime -ge (Get-Date).addhours(-168) -or $_.CreationTime -ge (Get-Date).AddHours(-168) -or $_.State -eq "Working")}) | Get-VBRTaskSession | Where-Object {$_.Status -notmatch "Idle|InProgress|Pending|Fail"-and $_.Info.Progress.TotalSize -ne "0"}

#Get Backup Job and VM
#$getOne = $vbrtasksessions | ? {$_.JobName -eq "%Veeam Backup or Backup Copy Name%" -and $_.Name -eq "%Name of Server%"}

#Or Get Whole Backup Job and average between all the machines
#$getOne = $vbrtasksessions | ? {$_.JobName -eq "%Veeam Backup or Backup Copy Name%"}

#Cannot Get Total usedSize in Backup 
Echo ListofAllFullSizesInBytes $getOne.Info.Progress.TotalSize
#Echo AverageTotalFullBackupSizeInGB $([Math]::Round([Decimal]($getOne.Info.Progress.TotalSize | Measure-Object -Average).Average/1GB, 2))
Echo ListofIntcrementalSizeinBytess $getOne.Info.Progress.TransferedSize
#Echo AverageIntSizeinGB  $([Math]::Round([Decimal]($getOne.Info.Progress.TransferedSize | Measure-Object -Average).Average/1GB, 2))
Echo RateofChangein% ((($getOne.Info.Progress.TransferedSize | Measure-Object -Average).Average/($getOne.Info.Progress.TotalSize | Measure-Object -Average).Average)*100)



Disconnect-VBRServer | out-null

Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests