Search This Blog

Wednesday, May 15, 2024

Exclude VM By Pattern for a Job with Selecting Host

 #Scenario 2: Exclude vm by the pattern for a job with the predefined host (entire vm on host)

#Error - will not work as no VM object on the backup job. Only Host with no vm

Connect-VBRServer -Server "VBR121RTM"

# Specify the name of the backup job and the name of the VM to exclude

$backupJobName = "Entire VM Backup Job By Host"

# Specify the vm extension to exclude

$vmNameToExclude = Get-VBRJobObject -Job $backupJobName -Name "*vm*"

Remove-VBRJobObject -Objects $vmNameToExclude

# Get the backup job object

$backupJob = Get-VBRJob -Name $backupJobName

#Save the backup Job

Set-VBRJobOptions -Job $backupJob