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 »

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
Veteran
Posts: 293
Liked: 19 times
Joined: Apr 13, 2011 12:45 pm
Full Name: Thomas McConnell
Contact:

Re: Create Application Group from Imported Backups

Post by ThomasMc »

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 »

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
Veteran
Posts: 293
Liked: 19 times
Joined: Apr 13, 2011 12:45 pm
Full Name: Thomas McConnell
Contact:

Re: Create Application Group from Imported Backups

Post by ThomasMc »

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
Veteran
Posts: 293
Liked: 19 times
Joined: Apr 13, 2011 12:45 pm
Full Name: Thomas McConnell
Contact:

Re: Create Application Group from Imported Backups

Post by ThomasMc »

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 »

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 16 guests