Page 1 of 1

VMs duplicated - Find-VBRViEntity

Veeam LogoPosted: Tue Feb 23, 2016 8:10 pm
by sburgess
Hi,

We are using powershell to get a list of VMs that we want to add to a backup job. Once we have the list in an array, we pass that to Find-VBRViEntity, but the resulting dataset results in each VM being added to the job twice:

Code: Select all
$dc = Get-cluster -Name $Cluster
$vms = Get-VM -Location $dc
$Entity = Find-VBRViEntity -VMsAndTemplates -name $VMsToAdd
Add-VBRViJobObject -Job $Job -Entities $Entity


When I look at the contents of $vms it has each VM listed once.

When I look at the contents of $Entity, it has 2 entries for each VM:

Code: Select all
ConnHost               : Veeam.Backup.Core.Common.CHost
Type                   : Vm
Reference              : vm-100524
Id                     : be4990ef-0716-463e-896b-92ade225a97c_vm-100524
Name                   : vm1
Path                   : vcenter.domain.com\Datacenter\vm1
VmHostName             : esx006.domain.com
IsLegacyFaultTolerance : False
FaultToleranceType     : None
GuestInfo              : Veeam.Backup.Model.CGuestInfo
Uuid                   : 4211a96f-4c42-97aa-c0cc-329bdf95e4c1
PowerState             : PoweredOn
IsTemplate             : False
ProvisionedSize        : 59172530713
UsedSize               : 13365486931
ConnHostId             : be4990ef-0716-463e-896b-92ade225a97c

ConnHost               : Veeam.Backup.Core.Common.CHost
Type                   : Vm
Reference              : vm-100524
Id                     : 375bfcdb-55bb-406a-adf3-c89816f59a6a_vm-100524
Name                   : vm1
Path                   : vcenter.domain.com\Datacenter\vm1
VmHostName             : esx006.domain.com
IsLegacyFaultTolerance : False
FaultToleranceType     : None
GuestInfo              : Veeam.Backup.Model.CGuestInfo
Uuid                   : 4211a96f-4c42-97aa-c0cc-329bdf95e4c1
PowerState             : PoweredOn
IsTemplate             : False
ProvisionedSize        : 59172530713
UsedSize               : 13365486931
ConnHostId             : 375bfcdb-55bb-406a-adf3-c89816f59a6a

Re: VMs duplicated - Find-VBRViEntity

Veeam LogoPosted: Tue Feb 23, 2016 8:38 pm
by PTide
Hi and welcome to the community!

May I ask you where does $VMsToAdd variable gets its value from? Does it contain duplicate values as well?

Thank you.

Re: VMs duplicated - Find-VBRViEntity

Veeam LogoPosted: Wed Feb 24, 2016 3:16 pm
by sburgess
Apologies, when I was sanitizing the code I mismatched my variables. It gets the list from the "get-vm" command, and has no duplicates.

$dc = Get-cluster -Name $Cluster
$VMsToAdd = Get-VM -Location $dc
$Entity = Find-VBRViEntity -VMsAndTemplates -name $VMsToAdd
Add-VBRViJobObject -Job $Job -Entities $Entity

Re: VMs duplicated - Find-VBRViEntity

Veeam LogoPosted: Wed Feb 24, 2016 4:27 pm
by v.Eremin
What if you try the following example:

Code: Select all
$dc = Get-cluster -Name $Cluster
$VMsToAdd = Get-VM -Location $dc | select name -Unique
$Entity = Find-VBRViEntity -VMsAndTemplates -name $VMsToAdd
Add-VBRViJobObject -Job $Job -Entities $Entity


Thanks.

Re: VMs duplicated - Find-VBRViEntity

Veeam LogoPosted: Wed Feb 24, 2016 4:32 pm
by tsightler
It really looks like your Veeam server has the same vCenter added twice (perhaps once by name and another by IP or something?). I've trimmed the objects you've posted:

Code: Select all
Reference              : vm-100524
Id                     : be4990ef-0716-463e-896b-92ade225a97c_vm-100524
Name                   : vm1
Path                   : vcenter.domain.com\Datacenter\vm1
VmHostName             : esx006.domain.com
ConnHostId             : be4990ef-0716-463e-896b-92ade225a97c

Reference              : vm-100524
Id                     : 375bfcdb-55bb-406a-adf3-c89816f59a6a_vm-100524
Name                   : vm1
Path                   : vcenter.domain.com\Datacenter\vm1
VmHostName             : esx006.domain.com
ConnHostId             : 375bfcdb-55bb-406a-adf3-c89816f59a6a

Notice that the ConnHostId is different between the two although everything else appears to be identical. You can use the following two commands to find the servers from a Veeam perspective:
Code: Select all
Get-VBRServer | ?{$_.Id -eq "be4990ef-0716-463e-896b-92ade225a97c"}
Get-VBRServer | ?{$_.Id -eq "375bfcdb-55bb-406a-adf3-c89816f59a6a"}

My suggestion would be to get the correct name of the server that you want to be using, grab the server object, and pass that to the -Server parameter for Find-VBRViEntity so that you only return the specific object for the specific vCenter entry you want.

Re: VMs duplicated - Find-VBRViEntity

Veeam LogoPosted: Mon Feb 29, 2016 12:33 pm
by sburgess
That was exactly the problem, there was a second definition with a different name that pointed to the same VC.

Thanks!