From b063f1a833acaf0a684b80591ae783f5f8a28776 Mon Sep 17 00:00:00 2001 From: dyoder Date: Thu, 21 Jan 2021 12:32:59 -0500 Subject: [PATCH] fix Install-Wireguard.ps1 to properly launch after install add Install-AteraAgent.ps1 --- Install-AteraAgent.ps1 | 31 +++++++++++++++++++++++++++++++ Install-Wireguard.ps1 | 2 +- README.md | 5 +++-- 3 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 Install-AteraAgent.ps1 diff --git a/Install-AteraAgent.ps1 b/Install-AteraAgent.ps1 new file mode 100644 index 0000000..6b7029d --- /dev/null +++ b/Install-AteraAgent.ps1 @@ -0,0 +1,31 @@ +param( + [Parameter(Mandatory=$true)][int]$CUSTOMER_ID, + [Parameter(Mandatory=$true)][int]$INTEGRATOR_ID, + [Parameter(Mandatory=$false)][string]$AGENT_FILENAME="EmberkomAgentSetup.exe" +) + +## 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") ) +{ + ## 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 "The agent is already installed on this endpoint." } + + diff --git a/Install-Wireguard.ps1 b/Install-Wireguard.ps1 index 705b7fd..28dd359 100644 --- a/Install-Wireguard.ps1 +++ b/Install-Wireguard.ps1 @@ -12,7 +12,7 @@ If ( IsAdmin ) Catch { LogErr $_.Exception.Message ; Exit } ## Install manager service - Try { Start-Process "wireguard.exe" -ArgumentList '/installmanagerservice' -Wait -ErrorAction SilentlyContinue } + Try { Start-Process "${Env:ProgramFiles}\WireGuard\wireguard.exe" -ArgumentList '/installmanagerservice' -Wait -ErrorAction SilentlyContinue } Catch { LogErr $_.Exception.Message } ## Create shortcut on Public desktop diff --git a/README.md b/README.md index 5fa2628..5b6733b 100644 --- a/README.md +++ b/README.md @@ -3,5 +3,6 @@ Dot source any of the Powershell scripts with the following: . $([Scriptblock]::Create((New-Object Net.WebClient).DownloadString('$URL'))) -Dot source the Tools.ps1 script with the following: - . $([Scriptblock]::Create((New-Object Net.WebClient).DownloadString('https://dev.emberkom.com/emberkom/management-scripts/raw/branch/master/Tools.ps1'))) \ No newline at end of file +Dot source the Tools.ps1 script and run a live PS script: +. $([Scriptblock]::Create((New-Object Net.WebClient).DownloadString('https://dev.emberkom.com/emberkom/management-scripts/raw/branch/master/Tools.ps1'))) +Run-Script -LivePSScript Script-Name \ No newline at end of file