After the short introduction of the Veeam Powershell toolkit in my earlier post, It was about time to play with the Toolkit. In this post I will show you how to create a Backup Job and how to add VM’s to the backup job.
Lets start to add a new Veeam and Replication backup job called “Production” and add the following VM’s: DC01, VC01 and MC01:
$vbrserver = Get-VBRServer | Where {$_.Type -eq "Local"}
$vbrjobname = "Production"
$vbrfolder = "C:\veeam\production\"
$vbrfile = "production.vbk"
$vbrobjects = "DC01","VC01","MC01"
Add-VBRBackupJob -Name $vbrjobname -Type VDDK -Server $vbrserver `
-Folder $vbrfolder -FileName $vbrfile -Objects $vbrobjects
The backup job is created and the following output will be generated on the console:

You can verify the Job settings and the selected VM’s inside the GUI:

If you want to add an extra VM to the backup job. You can run the following code to add a VM called NAGIOS:
$vbrjobname = "Production"
$vbrjob = Get-VBRJob | Where {$_.Name -eq $vbrjobname}
$vbrserver = Get-VBRServer | Where {$_.Type -eq "VC"}
$vbrobjects = "NAGIOS"
Add-VBRJobObject -Job $vbrjob -Server $vbrserver -Object $vbrobjects
Annotation: the $vbrserver parameter is different than the first script in this post. When you want to add an Object to an existing job, you need to use the vCenter server as the backup source instead of the Veeam Backup server because you need to add an object from vCenter server to the backup job. See help for more info:
get-help Add-VBRJobObject -Detailed
The output from the command:
NAME
Add-VBRJobObject
SYNOPSIS
Add VMs or VM containers to the existing job.
SYNTAX
Add-VBRJobObject [-Job] <CBackupJob> [-Server] <CHost> [-Objects] <String[]
> [-WarningAction <ActionPreference>] [-WarningVariable <String>] [<CommonP
arameters>]
Add-VBRJobObject [-Job] <CBackupJob> [-Server] <CHost> [-Entities] <CEntity
[]> [-WarningAction <ActionPreference>] [-WarningVariable <String>] [<Commo
nParameters>]
DESCRIPTION
Add VMs or VM containers to the existing backup, replication or copy job.
PARAMETERS
-Job <CBackupJob>
Provide an object of the existing backup, replication or copy job.
-Server <CHost>
Provide an object of the ESX/ESXi server on which VMs or VM containers
reside.
-Objects <String[]>
Provide objects of VMs or containers of VMs that you want to back up, r
eplicate or copy.
When the command completed successfully you will see the following output:

To be continued…