From a378cf2cc03026b214c4551e185e665aa72995fa Mon Sep 17 00:00:00 2001 From: ek-dyoder Date: Fri, 3 Oct 2025 14:32:21 -0400 Subject: [PATCH] initial commit --- Install-SyncroAgent.ps1 | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Install-SyncroAgent.ps1 diff --git a/Install-SyncroAgent.ps1 b/Install-SyncroAgent.ps1 new file mode 100644 index 0000000..1078696 --- /dev/null +++ b/Install-SyncroAgent.ps1 @@ -0,0 +1,27 @@ + +Function Install-SyncroAgent ([string]$URL) { + + # Exit if $URL is null or empty + If ([string]::IsNullOrEmpty($URL)) { + Write-Output "The URL parameter cannot be null or empty" + Exit 1 + } + + # Exit if running without admin rights + If (-not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { + Write-Output "This script must be run as an administrator" + Exit 1 + } + + # Download and install the Syncro Agent + $Installer = "${Env:TEMP}\SyncroInstaller.msi" + Try { (New-Object System.Net.WebClient).DownloadFile($URL,$Installer) } + Catch { Write-Error "The Syncro Agent installer could not be downloaded from ${URL}`n"+$_.Exception.Message ; Exit 1 } + If ( Test-Path $Installer ) { + Start-Process msiexec.exe -ArgumentList "/i ""${Installer}"" /qn /norestart" -Wait + Remove-Item $Installer -Force -ErrorAction SilentlyContinue + } Else { + Write-Error "The Syncro Agent installer was successfully downloaded but could not be found at ""${Installer}""" + Exit 1 + } +}