Custom script no longer works in Veeam 9.0

PowerShell script exchange

Custom script no longer works in Veeam 9.0

Veeam Logoby monsterlab » Wed Mar 30, 2016 3:19 pm

Hello all,

We have a custom PowerShell script that we use to generate a report each month to bill customers for consumed storage. It outputs a table that contains the name of the job, all VMs within that job, the actual size of the VM, and an approximation of the backup size for each VM. I have pasted the code below. We've been using this script since version 6.5 with no issues. Since upgrading to version 9, we are unable to get the "VMSize" and "BackupSize" to populate. I've done a bit of digging, and part of the issue appears to be that the "AuxData" property is no longer a part of the "GetObjectOibsAll" method. Does anyone have any ideas to help us get this script working in 9.0? Is there a new cmdlet or property that will give the same information that the "AuxData" property used to provide?

Thanks in advance!

Code: Select all
$CSVFile = "C:\scripts\VanCTRVeeam\VeeamBackup.csv"

Add-PSSnapIn VeeamPSSnapIn -ErrorAction SilentlyContinue

$cdate=Get-Date
$backups=@()
foreach ($bkp in Get-VBRBackup) {
    $DataSize = ($bkp.GetObjectOibsAll()|select -ExpandProperty AuxData|select -ExpandProperty RealVmSize|measure -sum).sum
    $BkpSize = ($bkp.GetStorages()|select -ExpandProperty Stats|select -ExpandProperty BackupSize|measure -sum).sum
    foreach ($obj in $bkp.GetObjectOibsAll()) {
        $vm = New-Object PSObject -Property @{
            BackupDate = $cdate
            JobName = $bkp.JobName
            VMName = $obj.Name
            VMSize  = $obj.AuxData.RealVmSize
            BackupPct = $obj.AuxData.RealVmSize / $DataSize
            BackupSize = $BkpSize * ($obj.AuxData.RealVmSize / $DataSize)
        }
        $backups += $vm
    }
    $DataSize = 0
    $BkpSize = 0
}
$backups|select BackupDate, JobName, VMName, VMSize, BackupSize |Export-Csv -NoTypeInformation $CSVFile
monsterlab
Novice
 
Posts: 5
Liked: never
Joined: Wed Aug 08, 2012 8:44 pm

Re: Custom script no longer works in Veeam 9.0

Veeam Logoby tsightler » Thu Mar 31, 2016 3:06 pm

I may not be fully understanding the script but I believe you can simply replace the following functions:

GetObjectOibsAll() --> GetLastOibs()
GetStorages() --> GetAllStorages()

I've never actually used GetObjectOibsAll() previously so I'm not exactly sure what it did in prior versions but in v9 it appears to simply return a list of all VM objects in the job. The GetLastOibs() should do the same, returning the most recent Oib for any VM in the job, and this object does include the AuxData property.
tsightler
Veeam Software
 
Posts: 4768
Liked: 1737 times
Joined: Fri Jun 05, 2009 12:57 pm
Full Name: Tom Sightler


Return to PowerShell



Who is online

Users browsing this forum: No registered users and 3 guests