Include Job Name in Get-VBRRestorePoint

PowerShell script exchange

Include Job Name in Get-VBRRestorePoint

Veeam Logoby brupnick » Fri 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!
brupnick
Expert
 
Posts: 196
Liked: 13 times
Joined: Sat Feb 05, 2011 5:09 pm
Location: New York, USA
Full Name: Brian Rupnick

Re: Include Job Name in Get-VBRRestorePoint

Veeam Logoby v.Eremin » Mon Mar 02, 2015 10:00 am

Try the following script:

Code: Select all
Get-VBRRestorePoint | select name, {$_.FindSourceJob().name}


Thanks.
v.Eremin
Veeam Software
 
Posts: 13281
Liked: 970 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Include Job Name in Get-VBRRestorePoint

Veeam Logoby brupnick » Wed 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.
brupnick
Expert
 
Posts: 196
Liked: 13 times
Joined: Sat Feb 05, 2011 5:09 pm
Location: New York, USA
Full Name: Brian Rupnick

Re: Include Job Name in Get-VBRRestorePoint

Veeam Logoby v.Eremin » Wed 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.
v.Eremin
Veeam Software
 
Posts: 13281
Liked: 970 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Include Job Name in Get-VBRRestorePoint

Veeam Logoby tsightler » Wed 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
tsightler
Veeam Software
 
Posts: 4769
Liked: 1737 times
Joined: Fri Jun 05, 2009 12:57 pm
Full Name: Tom Sightler

Re: Include Job Name in Get-VBRRestorePoint

Veeam Logoby brupnick » Thu 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.
brupnick
Expert
 
Posts: 196
Liked: 13 times
Joined: Sat Feb 05, 2011 5:09 pm
Location: New York, USA
Full Name: Brian Rupnick

Re: Include Job Name in Get-VBRRestorePoint

Veeam Logoby v.Eremin » Thu 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.
v.Eremin
Veeam Software
 
Posts: 13281
Liked: 970 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Include Job Name in Get-VBRRestorePoint

Veeam Logoby brupnick » Thu Mar 05, 2015 6:03 pm

Man, you guys are awesome. Thanks so much!!
brupnick
Expert
 
Posts: 196
Liked: 13 times
Joined: Sat Feb 05, 2011 5:09 pm
Location: New York, USA
Full Name: Brian Rupnick

Re: Include Job Name in Get-VBRRestorePoint

Veeam Logoby v.Eremin » Fri Mar 06, 2015 11:43 am

You're welcome. Don't hesitate to contact us, if other questions arise.
v.Eremin
Veeam Software
 
Posts: 13281
Liked: 970 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin


Return to PowerShell



Who is online

Users browsing this forum: Bing [Bot] and 5 guests