-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPerchInstaller.ps1
More file actions
67 lines (55 loc) · 1.9 KB
/
PerchInstaller.ps1
File metadata and controls
67 lines (55 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
Import-Module $env:SyncroModule
<#
.SYNOPSIS
Download the latest Perch Security log shipper agent, and get the cloud install
token from the customer profile, install silently.
.DESCRIPTION
Installs the Perch Security Log Shipper agent for threat hunting services via
Perch Security's SOC.
.INSTRUCTIONS
Create a custom field in your customer object (probably called "PerchToken" or
something like that), then add the script variable here called $perchy (set it
to a platform variable and find the value from your customer object). If you
want to set a default token to use should a customer-specific token not be available,
edit that below. This is optional, and nothing below that would need to be edited.
#>
$default_token = ""
$download_location = "https://cdn.perchsecurity.com/downloads/perch-log-shipper-latest.exe"
$use_token = $perchy
if ($use_token -eq "") {
$use_token = $default_token
}
function download_file($file_url, $save_to_path) {
(New-Object System.Net.WebClient).DownloadFile($file_url,$save_to_path)
if (Test-Path $save_to_path) {
return $true
}
return $false
}
function is_installed() {
if (Get-Service "perch-auditbeat" -ErrorAction SilentlyContinue) {
return $true
}
return $false
}
try {
if (is_installed) {
Write-Host "Perch log shipper is already installed."
}else {
$res = download_file $download_location "C:\perch-log-shipper-latest.exe"
if ($res) {
Start-Process "C:\perch-log-shipper-latest.exe" -ArgumentList "/qn","OUTPUT=`"TOKEN`"","VALUE=`"$use_token`"" -Wait
if (is_installed) {
Write-Host "Installation successful"
}else {
Write-Host "Installation failed"
}
}else {
Write-Host "Download failed."
}
}
} catch {
$error = $_.Exception.Message
Write-Output $error
exit -1
}