PowerCLI-Example-Scripts
PowerCLI-Example-Scripts copied to clipboard
exceed limit of open queries
Due to issue #466 we cant get a complete list of all our client anymore.
our first workaround: get a list of all pools and for each pool: get a list of machines of that pool - join them all together getting clients of an empty pool raises an error that we ignore (Due to issue #466)
This way i get the first 2570 machines we have, but after that i get an error when asking for the clients of the next pool:
Find-HVMachine : Exception calling "QueryService_Create" with "2" argument(s): "ExceptionType : VMware.Hv.InvalidState
ErrorMessage : Creating a new query would exceed the limit of open queries allowed
Id : "
At C:\Program Files\WindowsPowerShell\Modules\VMware.Hv.Helper\VMware.HV.Helper.psm1:7707 char:18
second workaround: we do it as the first workaround, but disconnect and reconnect to the HVServer every 4 Pools, because even asking for the clients of 10 pools can exceed the maximum limit of opened queries
$counter = 0 $pools = Get-HVPool $VMs = @() foreach($pool in $pools){ try{ if($counter -eq 5){ Disconnect-HVServer * -Force -Confirm:$false Connect-HVServer $HVserver -Force -User "someuser" -Password "somepassword" $counter = 0 } $counter +=1 $Clients = $null $Clients = Get-HVMachineSummary -PoolName $pool.Base.Name $VMs = @($VMs)+$clients [gc]::Collect() }catch{ write-host ("pool with errors: " + $pool.Base.Name) } }
Because we ask for the clients of each pool seperately pool by pool, i dont get why this should exceed the maximum number of queries. Seems like the queries are not closed after the result was received and Get-HVMachineSummary has finished? Or is there a query for each client that is found and we have more clients than supported?