PowerShell script exchange
Post Reply
vicentin
Novice
Posts: 4
Liked: never
Joined: Mar 09, 2020 3:49 pm
Contact:

Case #04970788 — Change Startup Options through powershell

Post by vicentin »

I am trying to use Powershell in order to change the "Startup options" (Verification Options) of an Application Group VM. The idea is to use scripting to change the "Maximum allowed boot time" or other parameters.
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
But, as far as I know, there is no way to change the Startup Options here.
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}
However, I get the error:
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
This is due to the fact that "cluster5" is a Hyper-V cluster (which hosts more than 130 VMs), instead of a VM itself.

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
However, the result is another error:
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
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.

Is there any way to change the Startup Options through Powershell scripting?
HannesK
Product Manager
Posts: 14333
Liked: 2895 times
Joined: Sep 01, 2014 11:46 am
Full Name: Hannes Kasparick
Location: Austria
Contact:

Re: Case #04970788 — Change Startup Options through powershell

Post by HannesK »

Hello,
sounds to be related to a limitation described directly / indirectly here ,here and here

As far as I understood, the problem is that VMs have to be added with New-VBRSureBackupVM to support -StartupOptions parameter. But New-VBRSureBackupVM can only work with VMs objects (Get-VBRJobObject -Job $job -Name "VM-name") that are added to a job directly. Not with containers like a cluster in your case, or VMware tags or VMware folders.

I'm pretty sure, that it is a limitation today. I just like to be sure that I understood the issue.

This works with a job where the VMs are added directly

Code: Select all

$job = Get-VBRJob -Name "BJ-important"
$backupobject = Get-VBRJobObject -Job $job -Name "HK-DC01"
$startup = New-VBRSureBackupStartupOptions -MaximumBootTime 200 -ApplicationInitializationTimeout 150 -AllocatedMemory 80 -EnableVMPingCheck -EnableVMHeartbeatCheck
$vm = New-VBRSureBackupVM -VM $backupobject -StartupOptions $startup
Add-VBRViApplicationGroup -VM $vm -Name "AG-test01"
This code

Code: Select all

$job = Get-VBRJob -Name "BJ-Tagbased"
$backupobject = Get-VBRJobObject -Job $job -Name "HK-Ubuntu2004-AD"
$startup = New-VBRSureBackupStartupOptions -MaximumBootTime 200 -ApplicationInitializationTimeout 150 -AllocatedMemory 80 -EnableVMPingCheck -EnableVMHeartbeatCheck
$vm = New-VBRSureBackupVM -VM $backupobject -StartupOptions $startup
Add-VBRViApplicationGroup -VM $vm -Name "AG-test02"
fails with

Code: Select all

New-VBRSureBackupVM : Cannot validate argument on parameter 'VM'. The argument is null. Provide a valid value for the argument, and then try running the command again.
At line:1 char:31
+ $vm = New-VBRSureBackupVM -VM $backupobject -StartupOptions $startup
+                               ~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [New-VBRSureBackupVM], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Veeam.Backup.PowerShell.Cmdlets.NewVBRSureBackupVM
because $backupobject is null.

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

Re: Case #04970788 — Change Startup Options through powershell

Post by oleg.feoktistov » 1 person likes this post

Hi,

Yes, exactly. Currently -VM parameter doesn't support job object types other than virtual machine. Further enhancement is now under consideration.

Thanks,
Oleg
woifgaung
Veeam Software
Posts: 51
Liked: 11 times
Joined: Oct 15, 2015 2:57 pm
Full Name: Wolfgang Scheer
Contact:

Re: Case #04970788 — Change Startup Options through powershell

Post by woifgaung »

I have to agree. I tried a lot to get SureBackup timeout changed with PowerShell. No way!
Wolfgang | CEMEA Solutions Architect | vnote42.net
vicentin
Novice
Posts: 4
Liked: never
Joined: Mar 09, 2020 3:49 pm
Contact:

Re: Case #04970788 — Change Startup Options through powershell

Post by vicentin »

Hello again!
That is what I thought: there is no solution for this issue.
Thank you everybody!
woifgaung
Veeam Software
Posts: 51
Liked: 11 times
Joined: Oct 15, 2015 2:57 pm
Full Name: Wolfgang Scheer
Contact:

Re: Case #04970788 — Change Startup Options through powershell

Post by woifgaung »

I must correct myself, there is a way. Maybe this workaround works for you:
powershell-f26/workaround-for-scripting ... 78332.html
Wolfgang | CEMEA Solutions Architect | vnote42.net
Post Reply

Who is online

Users browsing this forum: No registered users and 16 guests