upgrade to msi install and local config
This commit is contained in:
@@ -1,27 +1,30 @@
|
|||||||
param(
|
# NOTE: The $CONFIG variable must be set by the calling script
|
||||||
[Parameter(Mandatory=$true)][string]$URL
|
|
||||||
)
|
|
||||||
|
|
||||||
# Source the Tools.ps1 script
|
# Create temp directory
|
||||||
Function SourceTools
|
$TEMPDIR = '{0}eset-protect-deployment' -f (GetTempPath)
|
||||||
{ . $([Scriptblock]::Create((New-Object Net.WebClient).DownloadString('https://dev.emberkom.com/emberkom/management-scripts/raw/branch/master/Tools.ps1'))) }
|
LogMsg "Creating: ${TEMPDIR}"
|
||||||
. SourceTools
|
Try { New-Item -Path $TEMPDIR -ItemType Directory -Force -ErrorAction Stop }
|
||||||
|
Catch { LogErr $_.Exception.Message ; Exit }
|
||||||
|
|
||||||
|
# Write $CONFIG to install_config.ini
|
||||||
|
Try { $CONFIG | Out-File -FilePath "${TEMPDIR}\install_config.ini" -Force -ErrorAction Stop }
|
||||||
|
Catch { LogMsg "Cannot write configuration file! This script will exit." ; LogErr $_.Exception.Message ; Exit }
|
||||||
|
|
||||||
|
# Get bitness of endpoint and set $AGENTNAME
|
||||||
|
If ( Is64bit ) { $AGENTNAME = "agent_x64.msi" } Else { $AGENTNAME = "agent_x86.msi" }
|
||||||
|
|
||||||
# Download the installer
|
# Download the installer
|
||||||
$INSTALLER = '{0}epi_win_live_installer.exe' -f (GetTempPath)
|
$INSTALLER = "${TEMPDIR}\${AGENTNAME}"
|
||||||
LogMsg "Downloading ESET Management Agent live installer"
|
$URL = 'https://download.eset.com/com/eset/apps/business/era/agent/latest/{0}' -f $AGENTNAME
|
||||||
Try { Invoke-WebRequest -Uri $URL -UseBasicParsing -OutFile $INSTALLER }
|
LogMsg "Downloading ESET Management Agent"
|
||||||
Catch { LogErr $_.Exception.Message }
|
Download-File -URL $URL -File $INSTALLER
|
||||||
|
|
||||||
# Install the app
|
# Install the app
|
||||||
LogMsg "Installing ESET Management Agent from ""${INSTALLER}"""
|
LogMsg "Installing ESET Management Agent from ""${INSTALLER}"""
|
||||||
Try { Start-Process "${INSTALLER}" -ArgumentList "--silent --accepteula" -Wait }
|
Try { Start-Process "msiexec.exe" -ArgumentList "/i ${INSTALLER} /qn /norestart" -Wait }
|
||||||
Catch { LogErr $_.Exception.Message }
|
Catch { LogErr $_.Exception.Message }
|
||||||
|
|
||||||
# Delete the installer
|
# Delete the installer
|
||||||
LogMsg "Deleting downloaded installer ""${INSTALLER}"""
|
LogMsg "Deleting temp directory and its contents"
|
||||||
Try { Remove-Item -Path $INSTALLER -Force -ErrorAction SilentlyContinue }
|
Try { Remove-Item -Path $TEMPDIR -Recurse -Force -ErrorAction SilentlyContinue }
|
||||||
Catch { LogErr $_.Exception.Message }
|
Catch { LogErr $_.Exception.Message }
|
||||||
|
|
||||||
# Delete this script
|
|
||||||
Remove-Item $MyInvocation.MyCommand.Path -Force
|
|
||||||
|
|||||||
Reference in New Issue
Block a user