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
)