Okay, lets assume we have multiple vms with the name "dc01" in the same backup-job. The vm objects are directly attached to the backup job. So we can see multiple "dc01" entries when reviewing the job.
Now customer "tenant1" is deleting his vm, it disappears in vmm. With a powershell script, we would like to delete this vm from the veeam backup job. How can we accomplish this, that only this tenant1-dc01 is deleted and not every vm with the same name? We couldn't find a way to pass the unique ID to the CMDlet remove-VBRJobObject.
For example, we tried this:
Code: Select all
# Find the vms with name dc01 (in this example, there are two):
PS C:\Windows\system32> Find-VBRHvEntity -Name dc01
ConnHost : Veeam.Backup.Core.CHvDbScvmm
Type : Vm
Reference : b4314365-1aa7-4511-8242-b6b083ccf354
Id : 33321d5b-0e15-4122-85ec-7065ef2ee005_b4314365-1aa7-4511-8242-b6b083ccf354
Name : dc01
Path : vs9000100.zmsmgtlab.com\All Hosts\DC GLATTBRUGG\LAB\CLUSTERS\VV9000110.zmsmgtlab.com\dc01
VmHostName : VV9000110.zmsmgtlab.com
PowerState : PoweredOn
ProvisionedSize : 0
UsedSize : 0
GuestInfo : Veeam.Backup.Model.CGuestInfo
ConnHostId : 33321d5b-0e15-4122-85ec-7065ef2ee005
Platform : EHyperV
ConnHost : Veeam.Backup.Core.CHvDbScvmm
Type : Vm
Reference : fe92db84-ea96-4c08-87dc-ba743a8b9b85
Id : 33321d5b-0e15-4122-85ec-7065ef2ee005_fe92db84-ea96-4c08-87dc-ba743a8b9b85
Name : dc01
Path : vs9000100.zmsmgtlab.com\All Hosts\DC GLATTBRUGG\LAB\CLUSTERS\VV9000110.zmsmgtlab.com\dc01
VmHostName : VV9000110.zmsmgtlab.com
PowerState : PoweredOn
ProvisionedSize : 0
UsedSize : 0
GuestInfo : Veeam.Backup.Model.CGuestInfo
ConnHostId : 33321d5b-0e15-4122-85ec-7065ef2ee005
Platform : EHyperV
# I choose one of them with it's ID to make it unique and put it in a variable:
PS C:\Windows\system32> $VMsObj = Find-VBRHvEntity -Name dc01 | Where-Object{$_.id -eq "33321d5b-0e15-4122-85ec-7065ef2ee005_b4314365-1aa7-4511-8242-b6b083ccf354"}
# Now I have one single object:
PS C:\Windows\system32> $VMsObj
ConnHost : Veeam.Backup.Core.CHvDbScvmm
Type : Vm
Reference : b4314365-1aa7-4511-8242-b6b083ccf354
Id : 33321d5b-0e15-4122-85ec-7065ef2ee005_b4314365-1aa7-4511-8242-b6b083ccf354
Name : dc01
Path : vs9000100.zmsmgtlab.com\All Hosts\DC GLATTBRUGG\LAB\CLUSTERS\VV9000110.zmsmgtlab.com\dc01
VmHostName : VV9000110.zmsmgtlab.com
PowerState : PoweredOn
ProvisionedSize : 0
UsedSize : 0
GuestInfo : Veeam.Backup.Model.CGuestInfo
ConnHostId : 33321d5b-0e15-4122-85ec-7065ef2ee005
Platform : EHyperV
# Now let's pass it to remove-vbrjobobject. Nothing happens, no vm is deleted from the job after this command:
PS C:\Windows\system32> Get-VBRJob -Name "dummy_job" | Get-VBRJobObject -Name $VMsObj | Remove-VBRJobObject
# When I pass the name property of $VMsObj to remove-VBRJobObject, BOTH vms are deleted from the job.
PS C:\Windows\system32> Get-VBRJob -Name "dummy_job" | Get-VBRJobObject -Name $VMsObj.Name | Remove-VBRJobObject
Roland