| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 | [role="xpack"][testenv="platinum"][[sql-client-apps-ps1]]=== Microsoft PowerShellYou can use the {es} ODBC driver to access {es} data from Microsoft PowerShell.IMPORTANT: Elastic does not endorse, promote or provide support for this application; for native Elasticsearch integration in this product, please reach out to its vendor.==== Prerequisites* https://docs.microsoft.com/en-us/powershell/[Microsoft PowerShell]* {es-sql} <<sql-odbc, ODBC driver>>* A preconfigured User or System DSN (see <<dsn-configuration,Configuration>> section on how to configure a DSN).==== Writing a scriptWhile putting the following instructions into a script file is not an absolute requirement, doing so will make it easier to extend andreuse. The following instructions exemplify how to execute a simple SELECT query from an existing index in your {es} instance, using a DSNconfigured in advance. Open a new file, `select.ps1`, and place the following instructions in it:["source","powershell",subs="attributes,callouts"]--------------------------------------------$connectstring = "DSN=Local Elasticsearch;"$sql = "SELECT * FROM library"$conn = New-Object System.Data.Odbc.OdbcConnection($connectstring)$conn.open()$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)$conn.close()$dt--------------------------------------------Now open a PowerShell shell and simply execute the script:[[apps_excel_exed]].Run SQL in PowerShellimage:images/sql/odbc/apps_ps_exed.png[]// vim: set noet fenc=utf-8 ff=dos sts=0 sw=4 ts=4 tw=138 columns=140
 |