PowerShell script exchange
Post Reply
andrea.g
Novice
Posts: 6
Liked: never
Joined: Sep 29, 2017 1:19 pm
Contact:

Find-VBRViEntity and machine with duplicate names

Post by andrea.g »

Hello,
Veeam 9.0 + Vcenter 6.0

I've got in two virtual machines in two different folders .
I must backup only the backup under a specific folder.
The two machines hav the same name but different Ids and path.

How can i filter the VM using Find-VBRViEntity , and obtain only the VMs under a specific folder?

thank you
veremin
Product Manager
Posts: 20282
Liked: 2257 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Find-VBRViEntity and machine with duplicate names

Post by veremin »

Have you tried to use VmFolderName or Path parameter of ViEntity object? Thanks.
andrea.g
Novice
Posts: 6
Liked: never
Joined: Sep 29, 2017 1:19 pm
Contact:

Re: Find-VBRViEntity and machine with duplicate names

Post by andrea.g »

I will try
thank you!
veremin
Product Manager
Posts: 20282
Liked: 2257 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Find-VBRViEntity and machine with duplicate names

Post by veremin »

Let me know how things are going. Should need be, we will find a different way to approach this problem. Thanks.
andrea.g
Novice
Posts: 6
Liked: never
Joined: Sep 29, 2017 1:19 pm
Contact:

Re: Find-VBRViEntity and machine with duplicate names

Post by andrea.g »

I've tried with both, but both give me a

NamedParameterNotFound

error


Code: Select all

PS C:\Users\Administrator> Add-PSSnapin VeeamPSSnapin
$VMName =  "myVM"
$Folder = "esx1.domain.local\FOLDER\SUBFOLDER"
#Connect-VBRServer
 $VM = Find-VBRViEntity -Name $VMName -VMsAndTemplates  -Path "$Folder\$VMName"
 write-host $VM
Find-VBRViEntity : A parameter cannot be found that matches parameter name 'Path'.
At line:5 char:57
+  $VM = Find-VBRViEntity -Name $VMName -VMsAndTemplates  -Path "$Folder\$VMName"
+                                                         ~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Find-VBRViEntity], ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,Veeam.Backup.PowerShell.Command.FindVBRViEntity
 

PS C:\Users\Administrator> Add-PSSnapin VeeamPSSnapin
$VMName =  "myVM"
$Folder = "esx1.domain.local\FOLDER\SUBFOLDER"
#Connect-VBRServer
 $VM = Find-VBRViEntity -Name $VMName -VMsAndTemplates  -VMFolderName "$Folder\$VMName"
 write-host $VM
Find-VBRViEntity : A parameter cannot be found that matches parameter name 'VMFolderName'.
At line:5 char:57
+  $VM = Find-VBRViEntity -Name $VMName -VMsAndTemplates  -VMFolderName "$Folder\$ ...
+                                                         ~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Find-VBRViEntity], ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,Veeam.Backup.PowerShell.Command.FindVBRViEntity
 
andrea.g
Novice
Posts: 6
Liked: never
Joined: Sep 29, 2017 1:19 pm
Contact:

Re: Find-VBRViEntity and machine with duplicate names

Post by andrea.g »

discard my previous post.
tried using

Code: Select all

$myVM = $VM |  where {$_.Path -like "*$Folder\$VMName*" }
which returns nothing.
Dumping the vm list with

Code: Select all

$VM = Find-VBRViEntity -Name $VMName -VMsAndTemplates
$VM  | ConvertTo-Csv | Out-File "allvm.csv"
returns a "Path" field which does not report the path of the vm , but just
"esxi1.domain.local\vmname"
tsightler
VP, Product Management
Posts: 6011
Liked: 2843 times
Joined: Jun 05, 2009 12:57 pm
Full Name: Tom Sightler
Contact:

Re: Find-VBRViEntity and machine with duplicate names

Post by tsightler »

Reading between the lines it seems that this host may be added to Veeam directly, rather than via vCenter, because otherwise the path should definitely be "<vcenter_host>\<folder>\<folder>\<vmname>" but, if the ESXi hosts are added directly then there's no folder hierarchy because that's all kept in vCenter.
andrea.g
Novice
Posts: 6
Liked: never
Joined: Sep 29, 2017 1:19 pm
Contact:

Re: Find-VBRViEntity and machine with duplicate names

Post by andrea.g »

I've added the vcenter into the veeam interface .
now i can correctly see the vcenter\folder structure , but I can't see the single vm , only resource groups

Code: Select all

"d75ef525-0104-4118-a60f-1177367749cb_resgroup-v212","207032","vcenter.local\folder1\folder2\207032"
andrea.g
Novice
Posts: 6
Liked: never
Joined: Sep 29, 2017 1:19 pm
Contact:

Re: Find-VBRViEntity and machine with duplicate names

Post by andrea.g »

digged deeper into the issue.
it was just the vcenter which gave me error , returning 2 objects.
adding the Type -eq Vm filter fixed the filtering issue

Code: Select all

$VM = Find-VBRViEntity -Name $VMName -VMsAndTemplates | where {$_.Type -eq "Vm"}
veremin
Product Manager
Posts: 20282
Liked: 2257 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Find-VBRViEntity and machine with duplicate names

Post by veremin »

Good to know that you've finally fixed the issue. Thanks for coming back and updating the topic with the found resolution; much appreciate.
Post Reply

Who is online

Users browsing this forum: No registered users and 15 guests