PowerShell script exchange
Post Reply
wasd123
Novice
Posts: 5
Liked: never
Joined: Jul 10, 2023 6:18 am
Full Name: Nick Wecker
Contact:

Manage ShureBackup jobs with Powershell and the Veeam Cmdlet

Post by wasd123 »

Hello,

I'm currently working on a script to edit the testscripts of a Linked Job of a ShureBackup job via Powershell, but I'm not really successful.
Here is a small script that should add a Linked Job to the exsisting ShureBackup job "SHURETEST" but instead of adding, it delets all other Linked Jobs and creates the Linked Job with the testscript "HTTP Port".

The Veeam documentation isnt really clear and has a lot of mistakes that makes it hard to understand.
Does somebody know what I'm doing wrong or is there a better way to do it?

The Goal is to manage a lot of Shurebackup Jobs and Linked Jobs in the Future with costum scripts.
The manual way takes to long and is a lot of work in our envoirment so it would be nice if I can do all of the work with just a few scripts.

Here is the Veeam Documentation:
https://helpcenter.veeam.com/docs/backu ... ml?ver=120

Here is my script.

Code: Select all

$nametestscript = "HTTP Port"
$Port = "%vm_ip% 80"

$namelinkedjob = "LINKED JOB"
$job = Get-VBRJob -Name $namelinkedjob

$nameshurebackupjob = "SHURETEST"
$surejob = Get-VBRSureBackupJob -Name $nameshurebackupjob

$script = New-VBRSureBackupTestScript -Name $nametestscript  -Path "C:\Program Files\Veeam\Backup and Replication\Backup\Veeam.Backup.ConnectionTester.exe" -Argument $Port
$Test = New-VBRSureBackupLinkedJob -Job $job -TestScript $script

Set-VBRSureBackupJob -Job $surejob -LinkedJob $Test
david.domask
Veeam Software
Posts: 2123
Liked: 513 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: Manage ShureBackup jobs with Powershell and the Veeam Cmdlet

Post by david.domask » 1 person likes this post

Hi @wasd123,

The issue is that Set-VBRSureBackupJob will overwrite the previous value for the LinkedJobs the way you're doing it.

Try the following:

Code: Select all

$SBJob = Get-VBRSureBackupJob
$LinkedJobs = $SBJob.LinkedJob
$job = Get-VBRJob -name "name of job you want to add"
$LinkedJobs += New-VBRSureBackupLinkedJob -Job $job
Set-VBRSureBackupJob -Job $SBJob -LinkedJob $LinkedJobs
David Domask | Product Management: Principal Analyst
wasd123
Novice
Posts: 5
Liked: never
Joined: Jul 10, 2023 6:18 am
Full Name: Nick Wecker
Contact:

Re: Manage ShureBackup jobs with Powershell and the Veeam Cmdlet

Post by wasd123 »

Thanks @david.domask

Now the other Linked Jobs do not get deleted. :)
Is there a way to create multiple testscripts with the creation of one Linked Job? Maybe with an array?

new script:

Code: Select all

$nametestscript = "HTTP Port"
$Port = "%vm_ip% 80"


$SBJob = Get-VBRSureBackupJob -Name "SHUREBACKUPJOB"


$LinkedJobs = $SBJob.LinkedJob

$job = Get-VBRJob -name "JOB NAME"


$script = New-VBRSureBackupTestScript -Name $nametestscript  -Path "C:\Program Files\Veeam\Backup and Replication\Backup\Veeam.Backup.ConnectionTester.exe" -Argument $Port

$LinkedJobs += New-VBRSureBackupLinkedJob -Job $job -TestScript $script


Set-VBRSureBackupJob -Job $SBJob -LinkedJob $LinkedJobs
oleg.feoktistov
Veeam Software
Posts: 2010
Liked: 670 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Manage ShureBackup jobs with Powershell and the Veeam Cmdlet

Post by oleg.feoktistov » 1 person likes this post

Hi Nick,

Yes, New-VBRSureBackupLinkedJob accepts an array of test script objects, so you could create an array of scripts and pass it there. For example:

Code: Select all

$scripts = @()
$filePaths = Get-Content -Path "C:\Users\Administrator\Documents\ScriptPaths.txt"
foreach ($file in $filePaths) {
  $varName = 0
  $script = New-VBRSureBackupTestScript -Name "test script $($varName)" -Path $file
  $scripts += $script
  $varName += 1
}
New-VBRSureBackupLinkedJob -Job $job -TestScript $script
Best regards,
Oleg
wasd123
Novice
Posts: 5
Liked: never
Joined: Jul 10, 2023 6:18 am
Full Name: Nick Wecker
Contact:

Re: Manage ShureBackup jobs with Powershell and the Veeam Cmdlet

Post by wasd123 »

Hello,
thanks for the Help.
I have a few more Questions

Is it Possible to add Single VMs in the "Linked Jobs" section instead of the complete Backupjob with a script?
In the Dokumentation it is only described for Application Groups.
https://helpcenter.veeam.com/docs/backu ... ml?ver=120

Is there a way to uncheck the "Automatically Disbale Firewall" Checkbox in the Startup Options?
I cant find it in this Artikel:
https://helpcenter.veeam.com/docs/backu ... ml?ver=120
oleg.feoktistov
Veeam Software
Posts: 2010
Liked: 670 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Manage ShureBackup jobs with Powershell and the Veeam Cmdlet

Post by oleg.feoktistov »

Hi,
Is it Possible to add Single VMs in the "Linked Jobs" section instead of the complete Backupjob with a script?
In the Dokumentation it is only described for Application Groups.
Correct, you will still need to have a linked job.
Is there a way to uncheck the "Automatically Disbale Firewall" Checkbox in the Startup Options?
Good catch, this option will be available later in one of the next releases.

Best regards,
Oleg
wasd123
Novice
Posts: 5
Liked: never
Joined: Jul 10, 2023 6:18 am
Full Name: Nick Wecker
Contact:

Re: Manage ShureBackup jobs with Powershell and the Veeam Cmdlet

Post by wasd123 »

Hi,
Correct, you will still need to have a linked job.
sorry, I didn't explained it right.

I've meant if it's possible to set the "Advanced" settings in The "Linked Jobs" section of a Shurebackupjob thure CLI.
In the Advanced settings of the GUI it is possible to set startup options and test scripts per VM.
oleg.feoktistov
Veeam Software
Posts: 2010
Liked: 670 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Manage ShureBackup jobs with Powershell and the Veeam Cmdlet

Post by oleg.feoktistov »

Hi Nick,

Yes, it's possible with Set-VBRSureBackupVM cmdlet. For example, that's how I would set rules for one vm in one of the two linked jobs:

Code: Select all

$job = Get-VBRSureBackupJob -Name ''SureBackup Job 1'
$linkedJobs = $job.LinkedJob
$vm1 = Set-VBRSureBackupVM -VM $linkedJobs[0].VM[0] -Role DNSServer
$vms = @()
$vms += $vm1
$vms += $linkedJobs[0].VM[1]
$linkedJob1 = Set-VBRSureBackupLinkedJob -LinkedJob $linkedJobs[0] -VM $vms
$newLinkedJobs = @()
$newLinkedJobs += $linkedJob1
$newLinkedJobs += $linkedJobs[1]
Set-VBRSureBackupJob -Job $job -LinkedJob $newLinkedJobs
Best regards,
Oleg
wasd123
Novice
Posts: 5
Liked: never
Joined: Jul 10, 2023 6:18 am
Full Name: Nick Wecker
Contact:

Re: Manage ShureBackup jobs with Powershell and the Veeam Cmdlet

Post by wasd123 »

Hi,

wenn testing your code I get the error:
"the argument for parameter "VM" cannot be null" in line:
$vm1 = Set-VBRSureBackupVM -VM $linkedJobs[0].VM[0] -Role DNSServer

My Shurebackupjob contains 2 linked jobs. Each linked job contains 1 vm

"Write-Host $job" spits out the right name of the Shurebackupjob

"Write-Host $linkedJobs" spits out this:
Veeam.Backup.PowerShell.Infos.VBRSureBackupLinkedJob Veeam.Backup.PowerShell.Infos.VBRSureBackupLinkedJob

Code: Select all

$job = Get-VBRSureBackupJob -Name 'SHURETEST'
$linkedJobs = $job.LinkedJob
Write-Host $job
Write-Host $linkedJobs
$vm1 = Set-VBRSureBackupVM -VM $linkedJobs[0].VM[0] -Role DNSServer
$vms = @()
$vms += $vm1
$vms += $linkedJobs[0].VM[1]
$linkedJob1 = Set-VBRSureBackupLinkedJob -LinkedJob $linkedJobs[0] -VM $vms
$newLinkedJobs = @()
$newLinkedJobs += $linkedJob1
$newLinkedJobs += $linkedJobs[1]
Set-VBRSureBackupJob -Job $job -LinkedJob $newLinkedJobs
Post Reply

Who is online

Users browsing this forum: No registered users and 11 guests