PowerShell script exchange
Post Reply
monsterlab
Novice
Posts: 5
Liked: never
Joined: Aug 08, 2012 8:44 pm
Contact:

Custom script no longer works in Veeam 9.0

Post by monsterlab »

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
tsightler
VP, Product Management
Posts: 6013
Liked: 2843 times
Joined: Jun 05, 2009 12:57 pm
Full Name: Tom Sightler
Contact:

Re: Custom script no longer works in Veeam 9.0

Post by tsightler »

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.
acepero
Novice
Posts: 7
Liked: never
Joined: Feb 10, 2020 7:46 am
Full Name: Alberto Cepero
Contact:

Re: Custom script no longer works in Veeam 9.0

Post by acepero »

I know this post is already old, but retaking, the Script with the corrections, works fine except for this error:

select : Property "RealVmSize" cannot be found.
At line:8 char:68


Could someone tell me why?
nielsengelen
Product Manager
Posts: 5636
Liked: 1181 times
Joined: Jul 15, 2013 11:09 am
Full Name: Niels Engelen
Contact:

Re: Custom script no longer works in Veeam 9.0

Post by nielsengelen »

Hi Alberto, the script is 4 years old indeed and over time things have changed. There are other available on the forums to list VM size such as this one.
Personal blog: https://foonet.be
GitHub: https://github.com/nielsengelen
Post Reply

Who is online

Users browsing this forum: No registered users and 23 guests