PowerShell script exchange
Post Reply
Daniel2
Enthusiast
Posts: 45
Liked: 21 times
Joined: Nov 25, 2019 8:16 am
Full Name: Daniel
Contact:

Find-VBRViEntity inconsistent results

Post by Daniel2 »

Hi,

The behaviour of Find-VBRViEntity is a bit inconsistent and could need improvement.

Using Find-VBRViEntity without any parameters and switches, I would expect to return all existing entities, regardless of type or attribute. However, that is not the case. Check the count of the Vm types in the image below, for example. They contain the smallest set of VM entities across the tested switches.

Using the -VMsAndTemplates switch I would expect to get all VM entities (regardless of the IsTemplate attribute). However, the -DatastoresAndVMs returns a even higher count of VMs.

-Tag is the only switch that does what it says and returns only tags.

If I want to retrieve all entities, I would have to run the cmdlet multiple times with multiple switches and merge the results. If I want to retrieve all VMs, I have to do a similar thing. That's really complicated.

Suggestion:
Instead of using switches with odd combinations, why not use a ValidateSet?

Code: Select all

Param(
    [ValidateSet('Vm', 'VmTemplate', 'Tag', 'Datastore')] # ... and so on
    [string[]]$Type
)
Image
Daniel2
Enthusiast
Posts: 45
Liked: 21 times
Joined: Nov 25, 2019 8:16 am
Full Name: Daniel
Contact:

Re: Find-VBRViEntity inconsistent results

Post by Daniel2 »

There's more.

Depending on the Switch, the Path attribute differs.

-VmsAndTemplates adds the Path in the form of VC/Datacenter/Folderpath/VM
-HostsAndClusters adds the Path in the form of VC/Datacenter/Cluster/VM

If I need VMs and Templates with Cluster and the Folderpath, then I need to run both cmdlets, merge the output and still do not have the cluster for the templates, because templates are not returned when using -HostsAndClusters.

I'm working on an automated reporting script and stuff like this makes it really complicated to start.
oleg.feoktistov
Veeam Software
Posts: 2010
Liked: 670 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Find-VBRViEntity inconsistent results

Post by oleg.feoktistov »

Hi Daniel,

Find-VBRViEntity was implemented to mirror hierarchy objects explorer from the VBR UI. It means that -HostsAndClusters, -VMsAndTemplates etc. parameters are merely implementations of these views. So, what gets reflected in a specific view should be reflected when the corresponding parameter is used.

Now answering your specific questions:

- Using Find-VBRViEntity without any parameters is equivalent to using -HostsAndClusters parameter as this view is default in hierarchy objects explorer.
- One vm can be available via one view/parameter and not available via another if the view/parameter's usage implies it. For instance, vms of template type are not available in HostsAndClusters view, but available in VMsAndTemplates.
- With the validate set you suggested all the returned objects would need to have several path properties with values depending on logical containers they are located under (e.g. Folder, Resource Pool, Datastore). It sounds counterintuitive considering the fact the hierarchy explorer on VMware side is also implemented via views, not with such validate set.
- Path differs depending on the switch used because distinct view/parameter shows logical containers peculiar to this view. These logical containers are reflected in Path property.


Thanks,
Oleg
David_S
Novice
Posts: 3
Liked: never
Joined: Jan 21, 2020 1:56 pm
Full Name: David Sjöstrand
Contact:

Re: Find-VBRViEntity inconsistent results

Post by David_S »

Up until recently, Find-VBRViEntity -tags returned tagged vms which could be used to determine tag assignments. I used this to determine exactly which vms was included in jobs. Now there seem to be no way of doing this and all my scripts are broken.
Is there any other way of finding out the resulting set of vms that a job will back up?
oleg.feoktistov
Veeam Software
Posts: 2010
Liked: 670 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Find-VBRViEntity inconsistent results

Post by oleg.feoktistov »

Hi David,

It was fixed as a bug in v11a, but since it has been useful and was mentioned in official guide, we decided to rollback to this behavior of Find-VBRViEntity -Tags in v12. Please see this discussion.

Thanks,
Oleg
Post Reply

Who is online

Users browsing this forum: No registered users and 12 guests