VMware PowerCLI

The Best User Interface for your VMware Datacenter!

Add Parameter to various Get-* cmdlets to enable tag EXCLUSIVE functionality.

By default, the Get- entity cmdlets (e.g. Get-VM or Get-DatastoreCluster) that use tags, return inclusive sets. For example,

> Get-VM -Tag TagA,TagB,TagC

Will return any VM that has at least one of those 3 tags. Effectively operating like 'OR'

It would be nice to have a -ExclusiveTag or similar that changes the functionality to the opposite where it behaves like 'AND' to only return the entities that have ALL 3 tags applied.

Currently, it's a fairly painful process to either fetch all entities and their Tags and filter manually, or to interact with the CIS server to perform the filter in reverse to get the entities. It would seem to be much simpler and easier for users to implement this functionality in the PowerCLI source code where the query/API call is being built.

  • Jul 6 2023
  • Looking for Feedback
  • Attach files
  • Kamen Nikolov commented
    7 Jul, 2023 06:34am

    We will consider this idea. In the meantime as workaround you could do it like this:

    $vma = Get-VM -Tag TagA
    $vmb = Get-VM -Tag TagB
    $vmc = Get-VM -Tag TagC
    $vmAll = $vma | ? {$vmb -contains $_} | ? {$vmc -contains $_}