#* Load Veeam snapin
#asnp VeeamPSSnapin -ErrorAction SilentlyContinue
#* User Input
$jobName = "Backup Job"
$vmName = "VMtoBackup"
#* Find the job that has our VM
$job = Get-VBRBackup | ?{$_.JobName -eq $jobName}
$job2 = Get-VBRJob | ?{$_.Name -eq $jobName}
#* Get all objects in job apart from our target VM
$execObjs = foreach($v in $job.GetOibs()) {$v.VmName -ne $vmName}
#$execObjs = $job.GetObjectsInJob() | ?{$_.Name -ne $vmName}
#* Exclude the objects from the job(*Note: this isn't removing the objects
#* from the job)
Remove-VBRJobObject -Job $job2 -Objects $execObjs
#* Start the job only backing upi the target VM
Start-VBRJob -Job $job2
#* Find the exclude job objects
$incObjs = $job2 | Get-VBRJobObject | ?{$_.Type -eq "Exclude"}
#* Delete the exclude objects(*Note: this tells VBR to include them again
foreach ($obj in $incObjs) {
$obj.Delete()
}
I need to get all VM from backup folder and exclude VM. I'm stuck here:
That script look familiar but as you already know won't be able to do what your trying at it relies on the VMs being add individually, I detailed a way that Vladimir has scripted so you should check out this post