Don't miss out on new posts! Sign up!

Veeam Powershell Automatically Add Backup Jobs

One of the great things with Veeam Backup & Replication is the integration with PowerShell and the ability to automate many of the job options using PowerShell.  This is extremely handy when it comes to mass creating Veeam jobs in your environment by simply being able to query a list of VMs from vCenter, etc.  Recently, I had to throw together a script to create Veeam jobs quickly in an environment using PowerShell.  Let’s take a look at how to with Veeam PowerShell automatically add backup jobs.


Veeam Powershell Automatically Add Backup Jobs

There are several commandlets we can utilize to get the VMs from our VMware environment over to our Veeam backup environment.  We can utilize the following Veeam commandlets to query and create the jobs:

Let’s look at the PowerShell Code block:

$backupjobs = get-content c:vms.txt
$Key = Get-VBREncryptionKey

$results = foreach ($backupjob in $backupjobs){
    Write-Host "Adding Backup job for $backupjob"
    find-vbrvientity -name $backupjob* | where-object {$_.VMFolderName -ne "SomeFolder"} | Add-VBRViBackupJob -Name $backupjob"_new" -BackupRepository 'MyRepo'
    Set-VBRJobAdvancedStorageOptions -Job $backupjob"_new" -EnableEncryption $true -EncryptionKey $Key
    Set-VBRJobSchedule -Job $backupjob"_new" -Periodicaly -FullPeriod 1 -PeriodicallyKind Hours
    $jobname=get-VBRJob -Name $backupjob"_new"
    $Options = $jobname.GetOptions()

$results | out-file c:copyjob.log -Append

In the above, we get the list of VMs from a get-content read of a text file.  This provides the list of VMs that we want to actually create the jobs for.  We set a variable to get the encryption key for easy usage.

Now we actually start looping through the VMs.  We use the Find-VBRViEntity to find the name of the VM in our vSphere environment.  Then for this VM, we use the Add-VBRViBackupJob commandlet to create the job based on the name of the VM.  Here I am appending the “_new” to the name for a special use case.  For most you may not want to append anything.  With the Set-VBRJobSchedule we set the job schedule parameters.  Here I am setting the schedule to backup the VM every hour.

In the final section of the block, since there isn’t a Veeam PowerShell commandlet for this purpose (that I could find), I am using this chunk of code to set the number of Retension points that we want to keep for each job.

Finally, we log the results to a variable if we want to use this or simply create the log file.


The above is certainly a gorilla script without much time for commenting or any other creative work, however, we can see the power of using Veeam Powershell Automatically Add Backup Jobs to our environment and change settings of these on the fly as they are created.  This is a much easier way of creating multiple jobs than using the wizard for each individual one. [jetpack-related-posts]


Don't miss out on new posts! Sign up!

Brandon Lee

Brandon Lee is the Senior Writer, Engineer and owner at and has over two decades of experience in Information Technology. Having worked for numerous Fortune 500 companies as well as in various industries, Brandon has extensive experience in various IT segments and is a strong advocate for open source technologies. Brandon holds many industry certifications, loves the outdoors and spending time with family.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.