Advertisement
Guest User

Untitled

a guest
Apr 28th, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ######### Download Winbeat 5.2 ########
  2. $client = New-Object System.Net.WebClient
  3. $url =  “https://artifacts.elastic.co/downloads/beats/winlogbeat/winlogbeat-5.2.0-windows-x86_64.zip”
  4. $client.DownloadFile($url,$Env:temp\winlogbeat-5.2.0-windows-x86_64.zip”)
  5. cd $Env:temp
  6.  
  7. ######## Unzip file ########
  8. $shell_app = new-object -com shell.application
  9. $filename = "winlogbeat-5.2.0-windows-x86_64.zip"
  10. $zip_file = $shell_app.namespace("$env:temp\$filename")
  11.  
  12. #set the destination directory for the extracts
  13. if (!(Test-Path "$env:temp\Winlogbeat")) {
  14.     mkdir $env:temp\Winlogbeat
  15. }
  16. $destination = $shell_app.namespace("$env:temp\Winlogbeat")
  17.  
  18. #unzip the file
  19. $destination.Copyhere($zip_file.items())
  20.  
  21. ######### Copy file #########
  22. mkdir 'C:\Program Files\Winlogbeat'
  23. cp $env:temp\Winlogbeat\winlogbeat-5.2.0-windows-x86_64\* 'C:\Program Files\Winlogbeat'
  24.  
  25.  
  26. ######### Go to Winlogbeat directory ########
  27. cd 'C:\Program Files\Winlogbeat'
  28.  
  29. # Install Winbeat service
  30. Set-ExecutionPolicy RemoteSigned
  31. .\install-service-winlogbeat.ps1
  32.  
  33. ######## Winlogbeat ######
  34. #backup config
  35. cp winlogbeat.yml winlogbeat.yml.bak
  36.  
  37. # Disable elasticsearch
  38. (gc Winlogbeat.yml) -replace "output.elasticsearch:", "# output.elasticsearch:" | Set-Content -path winlogbeat.yml
  39. (gc Winlogbeat.yml) -replace '  hosts: \["localhost:9200"\]', '  # hosts: ["localhost:9200"]' | Set-Content -path winlogbeat.yml
  40.  
  41. # Enable logstash
  42. $domainName = Read-Host -Prompt 'Input your graylogserver domain: '
  43. (gc Winlogbeat.yml) -replace '#output.logstash:', 'output.logstash:' | Set-Content -path winlogbeat.yml
  44. (gc Winlogbeat.yml) -replace '  #hosts: \["localhost:5044"\]', "  hosts: [`"$($domainName):5044`"]" | Set-Content -path winlogbeat.yml
  45.  
  46. ######### Start Winlogbeat service ########
  47. Start-Service winlogbeat
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement