PowerShell script exchange
Post Reply
Shaft
Influencer
Posts: 17
Liked: never
Joined: Nov 05, 2013 3:06 pm
Full Name: Vince Rucolas
Contact:

Create Application Group with powershell

Post by Shaft »

I need to create application groups for a SureReplica job. This group will change and I would like to use powershell to create the groups and set up the startup options. I have reviewed the forums and come up with this script but I keep getting errors.

$appg = Get-VBRApplicationGroup -Name "test"


$StartOpts = New-VBRSureBackupStartupOptions -AllocatedMemory 50 -EnableVMHeartbeatCheck -MaximumBootTime 5400 -ApplicationInitializationTimeout 5000 -EnableVMPingCheck:$false -DisableWindowsFirewall

$VerOpts = New-VBRSureBackupVM -VM "fqdn vmname" -StartupOptions $StartOpts
Set-VBRApplicationGroup -ApplicationGroup $appg -VM $VerOpts

New-VBRSureBackupVM : Cannot bind parameter 'VM'. Cannot convert the "fqdn vmname" value of type "System.String" to type "Veeam.Backup.Core.CObjectInJob".
At line:8 char:37
+ $VerOpts = New-VBRSureBackupVM -VM "fqdn vmname" -StartupOptions $S ...
+ ~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [New-VBRSureBackupVM], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Veeam.Backup.PowerShell.Cmdlets.NewVBRSureBackupVM

Set-VBRApplicationGroup : Cannot validate argument on parameter 'VM'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.
At line:9 char:55
+ Set-VBRApplicationGroup -ApplicationGroup $appg -VM $VerOpts
+ ~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Set-VBRApplicationGroup], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Veeam.Backup.PowerShell.Cmdlets.SetVBRApplicationGroup



Any help would be much appreciated.
oleg.feoktistov
Veeam Software
Posts: 1918
Liked: 636 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Create Application Group with powershell

Post by oleg.feoktistov »

Hi Vince,

You are passing vm name to New-VBRSureBackupVM cmdlet instead of CObjectInJob object. And this cmdlet cannot do string to custom object conversion, hence the error.

You need to either get that vm as a job object first and pass it to -VM parameter:

Code: Select all

$job = Get-VBRJob -Name "Backup Job 1"
$vm = Get-VBRJobObject -Job $job -Name "fqdn vmname"
$VerOpts = New-VBRSureBackupVM -VM $vm -StartupOptions $StartOpts
Or get a backup of that vm and pass it to -RestorePoint parameter:

Code: Select all

$backup = Get-VBRBackup -Name "Backup Job 1"
$rps = Get-VBRRestorePoint -Backup $backup -Name "fqdn vmname"
$VerOpts = New-VBRSureBackupVM -RestorePoint $rps[0] -StartupOptions $StartOpts
Best regards,
Oleg
Shaft
Influencer
Posts: 17
Liked: never
Joined: Nov 05, 2013 3:06 pm
Full Name: Vince Rucolas
Contact:

Re: Create Application Group with powershell

Post by Shaft »

I see, That makes total sense.
In your second example showing how to set it using a restore point. I do not understand the $rps[0]

I changed your version slightly to do replicas and not backups. but when I run $rps[0] through $rps[6] (I have 7 snapshots to work with) the dates are not in order.

Code: Select all

$backup = Get-VBRReplica -Name "Backup Job 1"
$rps = Get-VBRRestorePoint -Backup $backup -Name "fqdn vmname"
$rps[7]


0 gives me the snap from 11/27
1 gives me the snap from 12/3
2 gives me the snap from 11/28
3 gives me the snap from 12/2
4 gives me the snap from 12/1
5 gives me the snap from 11/29
6 gives me the snap from 11/30

I would have expected them to be in some kind of order. Can you explain?

Thanks for your help.
oleg.feoktistov
Veeam Software
Posts: 1918
Liked: 636 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Create Application Group with powershell

Post by oleg.feoktistov »

Hi Vince,

By default Get-VBRRestorePoint cmdlet doesn't sort individual restore points by creation time. You'd need to use native powershell sort options to make it work:

Code: Select all

Get-VBRRestorePoint | sort -Property CreationTime -Descending
This will sort them by date starting from the recent one on the top.

Best regards,
Oleg
Shaft
Influencer
Posts: 17
Liked: never
Joined: Nov 05, 2013 3:06 pm
Full Name: Vince Rucolas
Contact:

Re: Create Application Group with powershell

Post by Shaft »

Interesting, Thanks for the help and getting back so soon. I think I am good at this point.
Post Reply

Who is online

Users browsing this forum: No registered users and 14 guests