Skip to content

Instantly share code, notes, and snippets.

@watson
Last active January 13, 2020 17:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save watson/1d1e5755a7878e5754c8430fb8a1ad5d to your computer and use it in GitHub Desktop.
Save watson/1d1e5755a7878e5754c8430fb8a1ad5d to your computer and use it in GitHub Desktop.
Install and run Elasticsearch in Windows PowerShell
Write-Host "Preparing to download and install Elasticsearch..." -ForegroundColor Cyan
$esVersion = "6.1.2"
$downloadUrl = "https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-$($esVersion).zip"
$zipPath = "$($env:USERPROFILE)\elasticsearch-$esVersion.zip"
$extractRoot = "$env:SYSTEMDRIVE\Elasticsearch"
$esRoot = "$extractRoot\elasticsearch-$esVersion"
Write-Host "Downloading Elasticsearch..."
(New-Object Net.WebClient).DownloadFile($downloadUrl, $zipPath)
7z x $zipPath -y -o"$extractRoot" | Out-Null
del $zipPath
Write-Host "Installing Elasticsearch as a Windows service..."
& "$esRoot\bin\elasticsearch-service.bat" install
Write-Host "Starting Elasticsearch service..."
& "$esRoot\bin\elasticsearch-service.bat" start
do {
Write-Host "Waiting for Elasticsearch service to bootstrap..."
sleep 1
} until(Test-NetConnection localhost -Port 9200 | ? { $_.TcpTestSucceeded } )
Write-Host "Elasticsearch installed" -ForegroundColor Green
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment