VMware Cloud Community
KennedyCMR
Contributor
Contributor
Jump to solution

Get-TagAssignment - query size limit exceeded

We are migrating custom attributes over to tags, but I am having an issue with creating automation to report tag memberships. It appears I need a way to increase the allowable query size limit. The reason I am doing this is because it seems to be the fastest way to compile an inventory of VM's and tags by creating an PSOject and then doing a lookup as needed, rather than looking up tags on a per VM basis.

Below is the command I am running and the error:

PowerCLI C:\> Get-TagAssignment -Category "Application Description"

Returns:

Get-TagAssignment : 2/28/2018 7:56:00 AM    Get-TagAssignment        com.vmware.vapi.std.errors.internal_server_error {'messages': [com.vmware.vapi.std.localizable_message {'id': vapi.bindings.method.impl.unexpected,
'default_message': Provider method implementation threw unexpected exception: The query size limit exceeded: filter.criteria.comparableValue list contains 636 items, but the limit is 128. Please refine your query
criteria., 'args': [The query size limit exceeded: filter.criteria.comparableValue list contains 636 items, but the limit is 128. Please refine your query criteria.]}], 'data':}
At line:1 char:1
+ Get-TagAssignment -Category "Application Description"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Get-TagAssignment], CisException
    + FullyQualifiedErrorId : VMware.VimAutomation.ViCore.Impl.V1.Service.Tagging.Cis.TaggingServiceCisImpl.GetTagAssignment.Error,VMware.VimAutomation.ViCore.Cmdlets.Commands.Tagging.GetTagAssignment

 

thanks for any help.

0 Kudos
1 Solution

Accepted Solutions
KennedyCMR
Contributor
Contributor
Jump to solution

For anyone else that has this issue, this was my nasty solution. Create a loop and only feed in blocks of VM's at a time. Takes about 3 minutes to do 760 VMs for a single category.

Also, VMware support didn't come back with anything helpful.

#### Example

$VMs = (Get-VM).Name

$NumVMs = $VMs.Count

$AppDescr = @()

$Lower = -100; $Upper = 0

while ($NumVMs -gt $Upper) {

  $Lower += 100

  $Upper += 100

  $AppDescr += (((Get-TagAssignment -Entity $VMs[$Lower..$Upper] -Category "Application Description").Entity).Name)

}

View solution in original post

0 Kudos
3 Replies
LucD
Leadership
Leadership
Jump to solution

I have seen that issue before, not sure if it was reported yet as a SR.

There are a number of bypasses:

  1. split up the Entities you feed into Get-TagAssignment
  2. use the PowerCLI Beta
  3. use my rCisTag module

Option 1 needs a rewrite of your script logic.

Option 2 & 3 use the REST API to query the Tag assignments


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
KennedyCMR
Contributor
Contributor
Jump to solution

thanks for those options, i'll check them out. We are also opening a support case and I will update this if we get any positive results from that angle.
0 Kudos
KennedyCMR
Contributor
Contributor
Jump to solution

For anyone else that has this issue, this was my nasty solution. Create a loop and only feed in blocks of VM's at a time. Takes about 3 minutes to do 760 VMs for a single category.

Also, VMware support didn't come back with anything helpful.

#### Example

$VMs = (Get-VM).Name

$NumVMs = $VMs.Count

$AppDescr = @()

$Lower = -100; $Upper = 0

while ($NumVMs -gt $Upper) {

  $Lower += 100

  $Upper += 100

  $AppDescr += (((Get-TagAssignment -Entity $VMs[$Lower..$Upper] -Category "Application Description").Entity).Name)

}

0 Kudos