Files
management-scripts/Install-AteraAgent.ps1
T
2021-01-27 11:35:21 -05:00

34 lines
1.4 KiB
PowerShell

param(
[Parameter(Mandatory=$true)][int]$CUSTOMER_ID,
[Parameter(Mandatory=$true)][string]$INTEGRATOR_ID,
[Parameter(Mandatory=$false)][string]$AGENT_FILENAME="EmberkomAgentSetup.exe",
[Parameter(Mandatory=$true)][switch]$FORCE=$true
)
## Source the Tools.ps1 script
Function SourceTools
{ . $([Scriptblock]::Create((New-Object Net.WebClient).DownloadString('https://dev.emberkom.com/emberkom/management-scripts/raw/branch/master/Tools.ps1'))) }
. SourceTools
## Build the path for $AGENT_INSTALLER
$AGENT_INSTALLER = '{0}{1}' -f (GetTempPath), $AGENT_FILENAME
## Make sure we need to install the agent
If ( Test-Path "${Env:ProgramFiles}\ATERA Networks\AteraAgent\AteraAgent.exe" ) { $INSTALL = $false } Else { $INSTALL = $true }
If ( $FORCE ) { $INSTALL = $true }
If ( $INSTALL ) {
## Download agent and get path
$AGENT_INSTALLER = Download-File -URL "http://emberkom.servicedesk.atera.com/GetAgent/Msi/?customerId=${CUSTOMER_ID}&integratorLogin=${INTEGRATOR_ID}" -File $AGENT_INSTALLER
## Install the agent
Try { Start-Process "msiexec.exe" -ArgumentList "/i ""${AGENT_INSTALLER}"" /qn /norestart" -Wait }
Catch { LogErr $_.Exception.Message }
## Remove agent installer
Try { Remove-Item $AGENT_INSTALLER -Force }
Catch { LogErr $_.Exception.Message }
} Else { LogMsg "Atera agent is already installed on this endpoint." }