Files
management-scripts/Install-ESETManagementAgent.ps1
T

40 lines
1.6 KiB
PowerShell
Raw Normal View History

2022-10-17 13:22:41 -04:00
# NOTE: The $CONFIG variable must be set by the calling script
2022-09-06 11:41:22 -04:00
2022-11-10 19:33:32 -05:00
# Set path to temp directory
$TEMPDIR = '{0}eset-protect-deployment' -f (Get-TempPath)
2022-10-17 13:22:41 -04:00
2022-11-10 19:29:55 -05:00
# Recursively delete $TEMPDIR if it already exists
If ( Test-Path $TEMPDIR ) {
2023-10-05 13:11:38 -04:00
Write-Output """${TEMPDIR}"" already exists and will be deleted"
2022-11-10 19:46:37 -05:00
Try { Remove-Item -Path $TEMPDIR -Recurse -Force -ErrorAction SilentlyContinue }
2023-10-05 13:17:18 -04:00
Catch { Write-Error $_.Exception.Message }
2022-11-10 19:29:55 -05:00
}
2022-11-10 19:33:32 -05:00
# Create $TEMPDIR
2023-10-05 13:11:38 -04:00
Write-Output "Creating: ${TEMPDIR}"
2022-11-10 19:33:32 -05:00
Try { New-Item -Path $TEMPDIR -ItemType Directory -Force -ErrorAction Stop }
2023-10-05 13:17:18 -04:00
Catch { Write-Error $_.Exception.Message ; Exit }
2022-11-10 19:33:32 -05:00
2022-10-17 13:22:41 -04:00
# Write $CONFIG to install_config.ini
2022-11-11 15:10:59 -05:00
Try { $CONFIG | WriteToFile_UTF8NoBOM -FilePath "${TEMPDIR}\install_config.ini" }
2023-10-05 13:17:18 -04:00
Catch { Write-Output "Cannot write configuration file! This script will exit." ; Write-Error $_.Exception.Message ; Exit }
2022-10-17 13:22:41 -04:00
# Get bitness of endpoint and set $AGENTNAME
If ( Is64bit ) { $AGENTNAME = "agent_x64.msi" } Else { $AGENTNAME = "agent_x86.msi" }
2022-09-02 15:16:37 -04:00
# Download the installer
2022-10-17 13:22:41 -04:00
$INSTALLER = "${TEMPDIR}\${AGENTNAME}"
2022-11-11 15:10:59 -05:00
$URL = 'https://download.eset.com/com/eset/apps/business/era/agent/latest/{0}' -f $AGENTNAME
2023-10-05 13:11:38 -04:00
Write-Output "Downloading ESET Management Agent"
2022-10-17 13:22:41 -04:00
Download-File -URL $URL -File $INSTALLER
2022-09-02 15:16:37 -04:00
# Install the app
2023-10-05 13:11:38 -04:00
Write-Output "Installing ESET Management Agent from ""${INSTALLER}"""
2022-11-11 13:37:50 -05:00
Try { Start-Process "msiexec.exe" -ArgumentList "/i ${INSTALLER} /qn /norestart /log installer.log" -Wait }
2023-10-05 13:17:18 -04:00
Catch { Write-Error $_.Exception.Message }
2022-09-02 15:16:37 -04:00
# Delete the installer
2023-10-05 13:11:38 -04:00
Write-Output "Deleting temp directory and its contents"
2022-11-11 15:20:57 -05:00
Try { Remove-Item -Path $TEMPDIR -Recurse -Force -ErrorAction SilentlyContinue }
2023-10-05 13:17:18 -04:00
Catch { Write-Error $_.Exception.Message }