Skip to content

Instantly share code, notes, and snippets.

@fulldeck
Forked from bferg314/elk_install.ps1
Last active January 25, 2019 08:25
Show Gist options
  • Save fulldeck/0c36e0fae3acca6036b530b16c7117b2 to your computer and use it in GitHub Desktop.
Save fulldeck/0c36e0fae3acca6036b530b16c7117b2 to your computer and use it in GitHub Desktop.
Download and Install ELK on Windows
# This install script will...
# Download and install ELK
# Install X-Pack
# Launch Elastic
# Run the set password script for elastic
# Change the version and the install path to whatever you want
$elk_version = "6.5.4"
$install_path = "c:/apps"
Add-Type -AssemblyName System.IO.Compression.FileSystem
Import-Module BitsTransfer
function Unzip
{
param([string]$zipfile, [string]$outpath)
Write-Host "Unziping $zipfile to $outpath"
[System.IO.Compression.ZipFile]::ExtractToDirectory($zipfile, $outpath)
Write-Host "$zipfile successfully unzipped to $outpath"
Write-Host ""
}
function dl{
param([string]$url, [string]$path)
if (!(Test-Path $path)) {
Write-Host "Downloading $url to $path"
Start-BitsTransfer -Source $url -Destination $path
# Invoke-WebRequest -Uri $url -OutFile $path
Write-Host "Successfully dowloaded $url to $path"
}
else {
Write-Host "$path already exists, skipping..."
}
Write-Host ""
}
Write-Host "Download code to download java current release, thanks shyiko/jabba"
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Invoke-Expression (
Invoke-WebRequest https://github.com/shyiko/jabba/raw/master/install.ps1 -UseBasicParsing
).Content
Write-Host "Install latest java release"
Write-Host ""
C:\apps\.jabba\jabba.exe install 1.8
Write-Host "Lets Check the Java Release"
Write-Host ""
Write-Host "Current Java Release:"
C:\apps\.jabba\jabba.exe ls
Write-Host "Beginning to gather ELK & X-pack"
# Create the install path
if (!(Test-Path $install_path)) {
New-Item -ItemType directory -Path $install_path
}
# Set the proxy if required
(New-Object System.Net.WebClient).Proxy.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials
# Set some paths
$file = "elasticsearch-$elk_version.zip"
$e_path = Join-Path $install_path $file
$url = "https://artifacts.elastic.co/downloads/elasticsearch/$file"
dl $url $e_path
$file = "logstash-$elk_version.zip"
$l_path = Join-Path $install_path $file
$url = "https://artifacts.elastic.co/downloads/logstash/$file"
dl $url $l_path
$file = "kibana-$elk_version-windows-x86_64.zip"
$k_path = Join-Path $install_path $file
$url = "https://artifacts.elastic.co/downloads/kibana/$file"
dl $url $k_path
Write-Host ""
Write-Host "File gathering complete... Unzipping."
Write-Host ""
$paths = $e_path, $l_path, $k_path
foreach ($path in $paths) {
$dir = Join-Path $install_path ([System.Io.Path]::GetFileNameWithoutExtension($path))
if (!(Test-Path $dir)) {
Unzip $path $install_path
}
else {
Write-Host "$dir already exists, skip unzip."
}
}
Write-Host ""
Write-Host "Installing X-Pack."
Write-Host ""
Write-Host "Installing LogStash X-Pack"
Set-Location (Join-Path $install_path "logstash-$elk_version\bin\elasticsearch-plugin install x-pack")
Write-Host "LogStash X-Pack Install Complete"
Write-Host "DON'T FORGET TO UPDATE kibana.yml WITH THE APPROPRIATE USERNAME AND PASSWORD!"
Write-Host ""
Write-Host "Install completed..."
Write-Host ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment