PowerShell script exchange
Post Reply
brupnick
Expert
Posts: 196
Liked: 13 times
Joined: Feb 05, 2011 5:09 pm
Full Name: Brian Rupnick
Location: New York, USA
Contact:

Include Job Name in Get-VBRRestorePoint

Post by brupnick » Feb 27, 2015 4:00 pm

Good morning-

Is there a way to run Get-VBRRestorePoint for a particular VM and have it return the name of the job that created the point? I'm trying to create a report that will give me the number of restore points for all the VMs in my environment. I'm using VMware tags to build my jobs, so I don't know the name of the job that a particular VM is in without running Get-VM to pull the tags. Unfortunately, running Get-VM for every VM in my environment is very slow and if I can get this from Get-VBRRestorePoint, it will save me quite a bit of time.

Any other suggestions are also welcomed.

Thanks!

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

Re: Include Job Name in Get-VBRRestorePoint

Post by veremin » Mar 02, 2015 10:00 am

Try the following script:

Code: Select all

Get-VBRRestorePoint | select name, {$_.FindSourceJob().name}
Thanks.

brupnick
Expert
Posts: 196
Liked: 13 times
Joined: Feb 05, 2011 5:09 pm
Full Name: Brian Rupnick
Location: New York, USA
Contact:

Re: Include Job Name in Get-VBRRestorePoint

Post by brupnick » Mar 04, 2015 2:04 pm

This is exactly what I was looking for. Thank you!

Now is there a quicker way to get the number of restore points for a particular VM? Right now, I'm using this

Code: Select all

$(Get-VBRRestorePoint -Name "SERVERNAME").Count
and it takes about 25 seconds to execute. With over 1,000 servers in my environment, you can see how this would be problematic. Ultimately, I'm looking to create a report that shows all the VMs in my environment along with the number of VBR restore points available.

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

Re: Include Job Name in Get-VBRRestorePoint

Post by veremin » Mar 04, 2015 2:33 pm

Besides counting actual restore points, nothing comes from the top of my head. As a side option, you can take a look at Veeam ONE (part of Availability Suite) that has reports you're looking for.

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

Re: Include Job Name in Get-VBRRestorePoint

Post by tsightler » Mar 04, 2015 4:22 pm 2 people like this post

brupnick wrote:Now is there a quicker way to get the number of restore points for a particular VM? Right now, I'm using this

Code: Select all

$(Get-VBRRestorePoint -Name "SERVERNAME").Count
and it takes about 25 seconds to execute. With over 1,000 servers in my environment, you can see how this would be problematic. Ultimately, I'm looking to create a report that shows all the VMs in my environment along with the number of VBR restore points available.
There are quite a number of ways to optimize, but one of the simplest is to minimize the number of times you have to call Get-VBRRestorePoint by just grabbing all of the points into a variable at once, so instead of your line above you would do:

Code: Select all

$restorepoints = Get-VBRRestorePoint
Then you can get the counts for each VM by doing:

Code: Select all

($restorepoints.Name -eq "SERVERNAME").Count
This will be much faster since you're calling Get-VBRRestorePoint only once and after that it's just using the in memory object. Of course there are even further optimizations you could potentially do. For example if you really only care about VM names and restore points counts you could load those directly into a hash table like so:

Code: Select all

(Get-VBRRestorePoint).Name | group | %{$rpcounts = @{}} {$rpcounts[$_.Name] = $_.Count}
The name becomes the key for the hash table, and the resource point count is the value so accessing the number of restore points for any specific VM is very fast and easy:

Code: Select all

$rpcounts["SERVERNAME"]
Now you can use this hash table to quickly and easily access the number of restore points for any give VM, or if you just wanted to output a nice sorted list of VM names and restore point counts you could do something like:

Code: Select all

$rpcounts = $rpcounts.GetEnumerator() | Sort-Object Name
Which would generate output something like:

Code: Select all

Name                           Value
----                           -----
Apache_Web                     22
dc01                           40
dc02                           55
exch01                         21
exch2013                       22
guac01                         14
it-vm01                        14
it-vm03                        14
it-vm04                        14
LAMP_vApp                      14

brupnick
Expert
Posts: 196
Liked: 13 times
Joined: Feb 05, 2011 5:09 pm
Full Name: Brian Rupnick
Location: New York, USA
Contact:

Re: Include Job Name in Get-VBRRestorePoint

Post by brupnick » Mar 05, 2015 4:23 pm

Tom, you are officially my new hero. What used to take 2+ hours is now down to 12 minutes thanks to you.

Here's what I ended up with, since I wanted to get the name of the job that processed the VM as well, and break them up as such:

Code: Select all

Get-VBRRestorePoint | Select Name, @{N="Job Name";E={$_.FindSourceJob().name}} | Group Name,"Job Name" -NoElement | Sort Name
The one thing that I noticed with this is that FindSourceJob() only returns values for current jobs; if a VM exists because it was imported, the imported job name will not be returned (but the restore points will). Is there a better way to retrieve this information for all VMs, including those that have been imported?

Again, THANK YOU so much for your help.

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

Re: Include Job Name in Get-VBRRestorePoint

Post by veremin » Mar 05, 2015 4:38 pm 1 person likes this post

What if you try this code, instead:

Code: Select all

Get-VBRRestorePoint | Select Name, @{N="Job Name";E={$_.FindBackup().Jobname}} | Group Name,"Job Name" -NoElement | Sort Name
Thanks.

brupnick
Expert
Posts: 196
Liked: 13 times
Joined: Feb 05, 2011 5:09 pm
Full Name: Brian Rupnick
Location: New York, USA
Contact:

Re: Include Job Name in Get-VBRRestorePoint

Post by brupnick » Mar 05, 2015 6:03 pm

Man, you guys are awesome. Thanks so much!!

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

Re: Include Job Name in Get-VBRRestorePoint

Post by veremin » Mar 06, 2015 11:43 am

You're welcome. Don't hesitate to contact us, if other questions arise.

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests