PowerShell script exchange
Post Reply
acasanovanex
Influencer
Posts: 12
Liked: 1 time
Joined: Apr 20, 2012 8:33 am
Contact:

Emulate recalculate button with powershell

Post by acasanovanex » Nov 09, 2012 10:22 am 1 person likes this post

Hello,

Is there a way to emulate the recalculate button functionality (when editing/creating a job) from a powershell script?

I've already explored the Veeam.Backup.Core.CBackupJob and Veeam.Backup.Core.CObjectInJob objects but I was unable to find a method to achieve such thing.

I know I can get the VM size from vCenter but I would rather do it through Veeam...

Thanks.
Ángel

Vitaliy S.
Product Manager
Posts: 22747
Liked: 1518 times
Joined: Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov
Contact:

Re: Emulate recalculate button with powershell

Post by Vitaliy S. » Nov 09, 2012 11:31 am

Hi Angel,

Not sure it is possible to emulate recalculate button with Veeam PowerShell commands (at least I haven't found a quick way to do that), so I would suggest using VMware's PowerCLI to calculate source VM data size.

Thanks!

acasanovanex
Influencer
Posts: 12
Liked: 1 time
Joined: Apr 20, 2012 8:33 am
Contact:

Re: Emulate recalculate button with powershell

Post by acasanovanex » Nov 10, 2012 2:16 pm

Thanks for your answer Vitaly.

gogotop
Lurker
Posts: 2
Liked: never
Joined: Jul 23, 2012 5:14 pm
Full Name: George Rusak
Contact:

Re: Emulate recalculate button with powershell

Post by gogotop » Nov 30, 2012 5:38 pm

I've been looking for a way to do this. Does anyone have a way to generate the size of the backup job via script?

We mave multiple backup jobs pointing to a single VMware cluster that has hundreds of VMs on it. We do this to meet the recommended backup size limits for backup jobs as recommended by Veeam. We want to get this value via script so we can write a report displaying the size of all the VMs in the backup job. This is used to allocate new machines in vCenter to the smallest sized backup job and as a notification for us to create a new backup job if the size limites have been reached. In vCenter VMs are placed into Resource Pools which are containers that are targeted in Veeam backup jobs. This way only the action of placing the machine into a VMware container is required to make sure its getting backed up. But the report really should come from the Veeam APIs as that is what we are trying to measure against. I found the value in $vbrjob.Info.IncludedSize. But it seems not to even populate unless the "Recalculate" button is pressed in the GUI, a tediously long process with lots of jobs. It was be very nice to get this action to happen automatically or via script.

Thanks!

Vitaliy S.
Product Manager
Posts: 22747
Liked: 1518 times
Joined: Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov
Contact:

Re: Emulate recalculate button with powershell

Post by Vitaliy S. » Nov 30, 2012 7:28 pm

gogotop wrote:Does anyone have a way to generate the size of the backup job via script?
Try the PS code discussed in this thread to get the info you need > Powershell script to report daily backup sizes

tsightler
VP, Product Management
Posts: 5374
Liked: 2208 times
Joined: Jun 05, 2009 12:57 pm
Full Name: Tom Sightler
Contact:

Re: Emulate recalculate button with powershell

Post by tsightler » Nov 30, 2012 8:02 pm

I don't know any way to force the "recalculate" button so that $vbrjob.Info.IncludedSize is updated, however, you should be able to get the equivalent by adding up the size of each Job Object within the job, which you can get from $vbrjob.GetObjectsInJob(). This will return an array of each object in the job, which will have a size available in the ApproxSizeString variable (for container objects it's the estimated used size of all VMs in the container). Unfortunately this value is a string so you have to manipulate it a little bit and add the values of all objects together. Something like the following should work:

Code: Select all

$job = Get-VBRJob -Name "Test Job"
$jobsize = 0
$job.GetObjectsInJob() | ForEach-Object {$jobsize = $jobsize + [decimal]($_.ApproxSizeString -replace " GB$")}
EDIT: I just noticed that this value isn't always updated either, but there is a "TryGetApproxSize()" method that I would think would be used to update an objects size info. I need to see if I can figure that out.

juacosta
Novice
Posts: 6
Liked: never
Joined: May 05, 2013 2:00 pm
Full Name: Juan Ramon Acosta
Contact:

[MERGED] : How to make wizard to show size of Resource Pool

Post by juacosta » May 06, 2013 12:52 pm

Hello everyone,

I am using power shell to create a backup job that specifies a VMWare Resource Pool instead of individual VMs. I noticed that when I specify the resource pool on the "Add-VBRViBackupJob" commandlet. The size of the resource pool is not shown on the column nor Total Size field on the "Virtual Machines" step of the wizard. However, if I press the "recalculate" button it pulls the correct size

Any tips how to achieve this thru the Veem backup PS

veremin
Product Manager
Posts: 16666
Liked: 1390 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Emulate recalculate button with powershell

Post by veremin » May 06, 2013 1:49 pm

To be honest, I can’t see any way of how this can be done using Veeam PowerShell Snap-in only. I can’t get it work neither by using ApproxSizeString nor by TryGetApproxSize() method (probably, some more qualified guy might correct me).

So, from my perspective, apart from pushing “recalculate” button this information can be only obtained from hypervisor directly via PowerCLI.

Hope this helps.
Thanks.

juacosta
Novice
Posts: 6
Liked: never
Joined: May 05, 2013 2:00 pm
Full Name: Juan Ramon Acosta
Contact:

Re: Emulate recalculate button with powershell

Post by juacosta » May 06, 2013 2:37 pm

Thanks everyone fro the quick answer. The script and post are very useful. One last question If I want the GUI to show the size after my Job is created is then the "Recalculate" push button the only option ?

tsightler
VP, Product Management
Posts: 5374
Liked: 2208 times
Joined: Jun 05, 2009 12:57 pm
Full Name: Tom Sightler
Contact:

Re: Emulate recalculate button with powershell

Post by tsightler » May 06, 2013 2:46 pm

I've also been unable to get this to work with previous attempts so for now it looks like the button press is the only option.

veremin
Product Manager
Posts: 16666
Liked: 1390 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Emulate recalculate button with powershell

Post by veremin » May 06, 2013 2:48 pm

One last question If I want the GUI to show the size after my Job is created is then the "Recalculate" push button the only option ?
Yep, it seems to be the only option.

Moreover, after having done it, you’ll be able to get the right size of the job objects even through PS, using the following example:

Code: Select all

asnp VeeamPSSnapin
$Job = Get-VBRJob -name "Name of your Job” 
$Job.info.IncludedSize 
Hope this helps.
Thanks.

juacosta
Novice
Posts: 6
Liked: never
Joined: May 05, 2013 2:00 pm
Full Name: Juan Ramon Acosta
Contact:

Re: Emulate recalculate button with powershell

Post by juacosta » May 07, 2013 7:30 pm

Thanks a lot Vladimir

veremin
Product Manager
Posts: 16666
Liked: 1390 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Emulate recalculate button with powershell

Post by veremin » May 08, 2013 8:11 am

Not a problem. Should any additional help be needed, let’s know.

Thanks.

boatmn810
Novice
Posts: 9
Liked: never
Joined: Aug 28, 2015 8:12 pm
Full Name: Jared
Contact:

Re: Emulate recalculate button with powershell

Post by boatmn810 » Aug 28, 2015 8:15 pm

V - is this supposed to refresh the backup jobs ?

Code: Select all

asnp VeeamPSSnapin
$Job = Get-VBRJob -name "Name of your Job” 
$Job.info.IncludedSize
I am using v8 ....2030 and it is not refreshing the backup jobs..
We are migrating from one vcenter server to a new one (changing versions as well.)
So refreshing the backup list would be a great thing to do...

veremin
Product Manager
Posts: 16666
Liked: 1390 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Emulate recalculate button with powershell

Post by veremin » Aug 31, 2015 10:41 am

Nope, as mentioned above, the provided command takes size as is. So, manual "Recalculation" is still needed. Once you run it, the given command will show the proper value. Thanks.

edirschedl
Enthusiast
Posts: 33
Liked: 4 times
Joined: Jul 21, 2016 12:29 pm
Full Name: Emanuel Dirschedl
Contact:

[MERGED] Get estimated total size in backup job config

Post by edirschedl » Oct 06, 2017 7:52 am

Hello,

is it possible to get the estimated "Total size" value on the backup job wizard (under the "Recalculate"-button) per Powershell?
If yes, with which command?

I need this information for some costs billing / accounting actions. I don't want to use the real size, because I need such information before the first backup starts.


Thank you,

Emanuel

veremin
Product Manager
Posts: 16666
Liked: 1390 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Emulate recalculate button with powershell

Post by veremin » Oct 06, 2017 10:46 am

Check the thread your post has been merged into. Some useful examples are provided above. Thanks.

billcouper
Service Provider
Posts: 68
Liked: 18 times
Joined: Dec 18, 2017 8:58 am
Full Name: Bill Couper
Contact:

Re: Emulate recalculate button with powershell

Post by billcouper » Jul 05, 2018 3:42 am 1 person likes this post

None of the above examples are useful, as everyone agrees that this is an impossible task using powershell.
According to this thread, the only way is to manually click the 'Recalculate' button in the GUI.

I too, would like a powershell method of doing this. Is there any change in v9.5 that provides the ability to do this simple task using powershell?
Manually clicking recalculate on dozens of jobs is mildly amusing, but only the first time.

veremin
Product Manager
Posts: 16666
Liked: 1390 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Emulate recalculate button with powershell

Post by veremin » Jul 09, 2018 1:32 pm

Is there any change in v9.5 that provides the ability to do this simple task using powershell?
Unfortunately, no changes in terms of recalculate cmdlet. Thanks.

evilaedmin
Enthusiast
Posts: 97
Liked: 12 times
Joined: Jul 26, 2018 8:04 pm
Full Name: Eugene V
Contact:

Re: Emulate recalculate button with powershell

Post by evilaedmin » Jan 30, 2019 6:55 pm

Any updates re: Update 4?

veremin
Product Manager
Posts: 16666
Liked: 1390 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Emulate recalculate button with powershell

Post by veremin » Feb 01, 2019 3:30 pm

No, Update 4 does not have a cmdlet for that. Thanks!

evilaedmin
Enthusiast
Posts: 97
Liked: 12 times
Joined: Jul 26, 2018 8:04 pm
Full Name: Eugene V
Contact:

Re: Emulate recalculate button with powershell

Post by evilaedmin » Aug 12, 2019 7:25 pm

Just curious, is this at all on the road map?

veremin
Product Manager
Posts: 16666
Liked: 1390 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Emulate recalculate button with powershell

Post by veremin » Aug 12, 2019 7:41 pm

It's tracked, yes, but it is not something we will implement in short-term future. Thanks!

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests