Files
management-scripts/Install-SyncroAgent.ps1
T

31 lines
1.2 KiB
PowerShell

param(
[Parameter(Mandatory=$true)][string]$URL,
[Parameter(Mandatory=$false)][string]$AGENT_FILENAME="SyncroInstaller.msi",
[Parameter(Mandatory=$false)][switch]$FORCE=$false
)
# Delete this script
Remove-Item $MyInvocation.MyCommand.Path -Force
# Exit early if we don't need to install the agent
If ( ($FORCE -eq $false) -and ((Test-Path "${Env:ProgramFiles}\RepairTech\Syncro\Syncro.App.Runner.exe") -or (Test-Path "${Env:ProgramFiles(x86)}\RepairTech\Syncro\Syncro.App.Runner.exe")) ) { Exit }
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 (Get-TempPath), $AGENT_FILENAME
# Download agent installer
Download-File -URL $URL -File "${AGENT_INSTALLER}"
# Install the agent
LogMsg "Installing Syncro agent from ""${AGENT_INSTALLER}"""
Try { Start-Process "msiexec.exe" -ArgumentList "/i ""${AGENT_INSTALLER}"" /qn /norestart" -Wait }
Catch { LogErr $_.Exception.Message }
# Delete the agent installer
LogMsg "Deleting ""${AGENT_INSTALLER}"""
Try { Remove-Item $AGENT_INSTALLER -Force }
Catch { LogErr $_.Exception.Message }