VMs duplicated - Find-VBRViEntity

PowerShell script exchange

VMs duplicated - Find-VBRViEntity

Veeam Logoby sburgess » Tue Feb 23, 2016 8:10 pm

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
sburgess
Novice
 
Posts: 3
Liked: never
Joined: Tue Feb 23, 2016 7:56 pm

Re: VMs duplicated - Find-VBRViEntity

Veeam Logoby PTide » Tue Feb 23, 2016 8:38 pm

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.
PTide
Veeam Software
 
Posts: 3022
Liked: 246 times
Joined: Tue May 19, 2015 1:46 pm

Re: VMs duplicated - Find-VBRViEntity

Veeam Logoby sburgess » Wed Feb 24, 2016 3:16 pm

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
sburgess
Novice
 
Posts: 3
Liked: never
Joined: Tue Feb 23, 2016 7:56 pm

Re: VMs duplicated - Find-VBRViEntity

Veeam Logoby v.Eremin » Wed Feb 24, 2016 4:27 pm

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.
v.Eremin
Veeam Software
 
Posts: 13288
Liked: 971 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: VMs duplicated - Find-VBRViEntity

Veeam Logoby tsightler » Wed Feb 24, 2016 4:32 pm

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.
tsightler
Veeam Software
 
Posts: 4769
Liked: 1737 times
Joined: Fri Jun 05, 2009 12:57 pm
Full Name: Tom Sightler

Re: VMs duplicated - Find-VBRViEntity

Veeam Logoby sburgess » Mon Feb 29, 2016 12:33 pm

That was exactly the problem, there was a second definition with a different name that pointed to the same VC.

Thanks!
sburgess
Novice
 
Posts: 3
Liked: never
Joined: Tue Feb 23, 2016 7:56 pm


Return to PowerShell



Who is online

Users browsing this forum: m.lazzarotto and 8 guests