PowerShell script exchange
Post Reply
mwpreston
Enthusiast
Posts: 73
Liked: 9 times
Joined: May 25, 2010 3:27 pm
Full Name: mike
Contact:

Create Application Group from Imported Backups

Post by mwpreston » 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

ThomasMc
Expert
Posts: 293
Liked: 17 times
Joined: Apr 13, 2011 12:45 pm
Full Name: Thomas McConnell
Contact:

Re: Create Application Group from Imported Backups

Post by ThomasMc » 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

mwpreston
Enthusiast
Posts: 73
Liked: 9 times
Joined: May 25, 2010 3:27 pm
Full Name: mike
Contact:

Re: Create Application Group from Imported Backups

Post by mwpreston » 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.

ThomasMc
Expert
Posts: 293
Liked: 17 times
Joined: Apr 13, 2011 12:45 pm
Full Name: Thomas McConnell
Contact:

Re: Create Application Group from Imported Backups

Post by ThomasMc » 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: Apr 13, 2011 12:45 pm
Full Name: Thomas McConnell
Contact:

Re: Create Application Group from Imported Backups

Post by ThomasMc » 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

mwpreston
Enthusiast
Posts: 73
Liked: 9 times
Joined: May 25, 2010 3:27 pm
Full Name: mike
Contact:

Re: Create Application Group from Imported Backups

Post by mwpreston » Jan 23, 2012 7:02 pm

Yes, the second option is exactly what I needed. Thanks so much! Mike

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests