ElasticSearch Query with Powershell Invoke-RestMethod

PowerShell doesn't support a GET request with a body, so you need to use POST instead as @dadoonet suggests.

If you need to work with Elasticsearch frequently with PowerShell, you may be interested in using Elastic.Console, a small PowerShell module that provides cmdlets for

  1. executing requests
  2. API path autocompletion
  3. ability to convert from and execute Kibana Console examples.
1 Like