PowerShell script exchange
Post Reply
sburgess
Novice
Posts: 3
Liked: never
Joined: Feb 23, 2016 7:56 pm
Contact:

VMs duplicated - Find-VBRViEntity

Post 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
PTide
Product Manager
Posts: 6431
Liked: 729 times
Joined: May 19, 2015 1:46 pm
Contact:

Re: VMs duplicated - Find-VBRViEntity

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

Re: VMs duplicated - Find-VBRViEntity

Post 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
veremin
Product Manager
Posts: 20284
Liked: 2258 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: VMs duplicated - Find-VBRViEntity

Post by veremin »

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.
tsightler
VP, Product Management
Posts: 6011
Liked: 2843 times
Joined: Jun 05, 2009 12:57 pm
Full Name: Tom Sightler
Contact:

Re: VMs duplicated - Find-VBRViEntity

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

Re: VMs duplicated - Find-VBRViEntity

Post by sburgess »

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

Thanks!
Post Reply

Who is online

Users browsing this forum: No registered users and 10 guests