Microsoft PowerShell

This functionality is experimental and may be changed or removed completely in a future release. Elastic will take a best effort approach to fix any issues, but experimental features are not subject to the support SLA of official GA features.


PowerShell is a task-based command-line shell and scripting language built on .NET.


PowerShell is available on all recent Windows Desktop OSes. It also has embedded ODBC support, thus offering a quick and accessible way to connect to Elasticsearch.


  • Microsoft PowerShell
  • Elasticsearch SQL ODBC driver
  • A preconfigured User or System DSN (see Configuration section on how to configure a DSN).

Writing a script

While putting the following instructions into a script file is not an absolute requirement, doing so will make it easier to extend and reuse. The following instructions exemplify how to execute a simple SELECT query from an existing index in your Elasticsearch instance, using a DSN configured in advance. Open a new file, select.ps1, and place the following instructions in it:

$connectstring = "DSN=Local Elasticsearch;"
$sql = "SELECT * FROM library"

$conn = New-Object System.Data.Odbc.OdbcConnection($connectstring)
$cmd = New-Object system.Data.Odbc.OdbcCommand($sql,$conn)
$da = New-Object system.Data.Odbc.OdbcDataAdapter($cmd)
$dt = New-Object system.Data.datatable
$null = $da.fill($dt)

Now open a PowerShell shell and simply execute the script:

Run SQL in PowerShell. apps ps exed