Imporved Invoke-ElasticSearch function.