At the beginning, I have written code like this:
Code: Select all
$VirtualLab = Get-VSBHvVirtualLab -Name $VirtualLabName
$AppGroup = Add-VSBHvApplicationGroup -Name $AppGroupName -VmFromBackup (Find-VBRHvEntity -Name "XXX")
$VsbJob = Add-VSBHvJob -Name $SbJobName -VirtualLab $VirtualLab -AppGroup $AppGroup -Description $SbJobDesc
Start-VSBJob -Job $VsbJob
I have seen the cmdlet "New-VBRSureBackupStartupOptions" and I have written something like this:
Code: Select all
$Startup = New-VBRSureBackupStartupOptions -AllocatedMemory 100 -EnableVMHeartbeatCheck:$true -EnableVMPingCheck:$false -MaximumBootTime 1000
$VBRJob = Get-VBRJob -Name "JobName"
$VBRVMs = Get-VBRJobObject -Job $VBRJob | Where-Object {$_.Name -eq "cluster5"}
$VSBVMs = @()
$VBRVMs | foreach {$VSBVMs += New-VBRSureBackupVM -VM $_ -StartupOptions $Startup}
This is due to the fact that "cluster5" is a Hyper-V cluster (which hosts more than 130 VMs), instead of a VM itself.New-VBRSureBackupVM : Specify VM parameter that is of VM type.
At line:1 char:31
+ ... each {$VSBVMs += New-VBRSureBackupVM -VM $_ -StartupOptions $Startup}
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [New-VBRSureBackupVM], Exception
+ FullyQualifiedErrorId : NewVBRSureBackupVMId,Veeam.Backup.PowerShell.Cmdlets.NewVBRSureBackupVM
In order to get VMs, I have run the following code:
Code: Select all
$job = get-vbrjob -name "Clus5"
$bkp = get-vbrbackup | Where-object {$_.jobid -eq $job.id}
$VMs=$bkp.GetObjects()
$VSBVM = New-VBRSureBackupVM -VM $bkp.GetObjects()[2] -StartupOptions $Startup
The problem here is that the "New-VBRSureBackupVM" cmdlet only accepts "CObjectInJob" objects, and, to get this kind of object, we only have the possibility to run the "Get-VBRJobObject" cmdlet, as far as I know.New-VBRSureBackupVM : Cannot bind parameter 'VM'. Cannot convert the "Name: VMName" value of type "Veeam.Backup.Core.CHierarchyObj" to type "Veeam.Backup.Core.CObjectInJob".
At line:1 char:35
+ $VSBVMs = New-VBRSureBackupVM -VM $bkp.GetObjects()[2] -StartupOption ...
+ ~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [New-VBRSureBackupVM], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Veeam.Backup.PowerShell.Cmdlets.NewVBRSureBackupVM
Is there any way to change the Startup Options through Powershell scripting?