Open MarkoKastner84 opened 3 years ago
How do you close the open queries?
I was using your example here to automate some DR Testing and entitling users to new machines we bring up. https://github.com/Magneet/Various_Scripts/blob/master/add_and_entitle_desktop.ps1
In the Get-HVMachineSummary or function Find-HVMachine function you can close the query service after you assign the result to a variable with the following command:
$query_service_helper.QueryService_Delete($services, $queryResults.id)
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:
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
}
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?