2021-01-21 12:32:59 -05:00
|
|
|
param(
|
|
|
|
|
[Parameter(Mandatory=$true)][int]$CUSTOMER_ID,
|
2021-01-21 12:41:31 -05:00
|
|
|
[Parameter(Mandatory=$true)][string]$INTEGRATOR_ID,
|
2021-01-27 11:35:21 -05:00
|
|
|
[Parameter(Mandatory=$false)][string]$AGENT_FILENAME="EmberkomAgentSetup.exe",
|
2021-01-27 12:28:28 -05:00
|
|
|
[Parameter(Mandatory=$false)][switch]$FORCE=$true
|
2021-01-21 12:32:59 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
## 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
|
2021-01-27 11:35:21 -05:00
|
|
|
If ( Test-Path "${Env:ProgramFiles}\ATERA Networks\AteraAgent\AteraAgent.exe" ) { $INSTALL = $false } Else { $INSTALL = $true }
|
|
|
|
|
If ( $FORCE ) { $INSTALL = $true }
|
|
|
|
|
If ( $INSTALL ) {
|
2021-01-21 12:32:59 -05:00
|
|
|
## 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 }
|
|
|
|
|
|
2021-01-24 07:12:52 -05:00
|
|
|
} Else { LogMsg "Atera agent is already installed on this endpoint." }
|
2021-01-21 12:32:59 -05:00
|
|
|
|
|
|
|
|
|