Create Application Group from Imported Backups

PowerShell script exchange

Create Application Group from Imported Backups

Veeam Logoby mwpreston » Fri Jan 20, 2012 7:24 pm

Hi,

Just wondering if anyone can help get me a bit further with my attempts..

What I want to do is import a bunch of backups, create an application group, create the surebackup job, and run it...all through powershell.

I've gotten myself to the point where I've imported the backups, but cannot seem to find a way to create the application group.

I know I need to use add-vsbapplicationgroup which is asking for a VM to put in the appgroup...how do i get the VM object out of my imported backups in order to add it to the application group?

Make sense?

Thanks for any help...
Mike
mwpreston
Veeam Vanguard
 
Posts: 73
Liked: 9 times
Joined: Tue May 25, 2010 3:27 pm
Full Name: mike

Re: Create Application Group from Imported Backups

Veeam Logoby ThomasMc » Fri Jan 20, 2012 9:04 pm

You need to do a bit of fetching but this will achieve what your looking for

Code: Select all
$vms = Get-VBRJob -Name "Imported Job" | Get-VBRJobObject
$vmAry = @()
foreach ($vm in $vms) {
   $vmHost = $vm.getobject().GetHost()
   $vmObj = Find-VBRObject -Server $vmHost -Name $vm.Name
   $vmAry = $vmAry + $vmObj
}

Add-VSBApplicationGroup -Name "Test App Group" -Vm $vmAry
ThomasMc
Expert
 
Posts: 293
Liked: 17 times
Joined: Wed Apr 13, 2011 12:45 pm
Full Name: Thomas McConnell

Re: Create Application Group from Imported Backups

Veeam Logoby mwpreston » Sat Jan 21, 2012 2:58 am

I guess i should have been a little more clear. I dont actually have a backup job imported. Just the backup files themselves. Is there a cmdlet i can use to do the same tasks with just the imported backups (not the job). Thanks so much for the help.
mwpreston
Veeam Vanguard
 
Posts: 73
Liked: 9 times
Joined: Tue May 25, 2010 3:27 pm
Full Name: mike

Re: Create Application Group from Imported Backups

Veeam Logoby ThomasMc » Sat Jan 21, 2012 12:05 pm

Ah, Sorry Mike :) try this way

Code: Select all
$vms = (Get-VBRBackup -Name "Imported Backup Files").GetObjects()
$vmAry = @()
foreach ($vm in $vms) {
   $vmHost = $vm.GetHost()
   $vmObj = Find-VBRObject -Server $vmHost -Name $vm.Name
   if ($vmHost.Type -eq "VC") {
      $vmAry = $vmAry + $vmObj[0]
   }
   else {
      $vmAry = $vmAry + $vmObj
   }
}
Add-VSBApplicationGroup -Name "Test App Group" -Vm $vmAry
ThomasMc
Expert
 
Posts: 293
Liked: 17 times
Joined: Wed Apr 13, 2011 12:45 pm
Full Name: Thomas McConnell

Re: Create Application Group from Imported Backups

Veeam Logoby ThomasMc » Sat Jan 21, 2012 12:41 pm

Having another think about it, this is more what your looking for I guess

Code: Select all
$ibfOibs = (Get-VBRBackup -Name "Imported Backup Files").GetLastOibs()
Add-VSBApplicationGroup -Name "Test App Group" -RestorePoint $ibfOibs
ThomasMc
Expert
 
Posts: 293
Liked: 17 times
Joined: Wed Apr 13, 2011 12:45 pm
Full Name: Thomas McConnell

Re: Create Application Group from Imported Backups

Veeam Logoby mwpreston » Mon Jan 23, 2012 7:02 pm

Yes, the second option is exactly what I needed. Thanks so much! Mike
mwpreston
Veeam Vanguard
 
Posts: 73
Liked: 9 times
Joined: Tue May 25, 2010 3:27 pm
Full Name: mike


Return to PowerShell



Who is online

Users browsing this forum: No registered users and 5 guests