Compare commits
2
Commits
9f6aefa71b
...
28bc9436ed
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
28bc9436ed | ||
|
|
d5e40c15a1 |
+27
-8
@@ -5,9 +5,6 @@
|
|||||||
[Parameter(Mandatory=$false)][switch]$FORCE
|
[Parameter(Mandatory=$false)][switch]$FORCE
|
||||||
)
|
)
|
||||||
|
|
||||||
# Replace the '@' with '%40' - not sure why this is necessary, but it is
|
|
||||||
$INTEGRATOR_ID = $INTEGRATOR_ID.Replace('@','%40')
|
|
||||||
|
|
||||||
# Source the Tools.ps1 script
|
# Source the Tools.ps1 script
|
||||||
Function SourceTools
|
Function SourceTools
|
||||||
{ . $([Scriptblock]::Create((New-Object Net.WebClient).DownloadString('https://dev.emberkom.com/emberkom/management-scripts/raw/branch/master/Tools.ps1'))) }
|
{ . $([Scriptblock]::Create((New-Object Net.WebClient).DownloadString('https://dev.emberkom.com/emberkom/management-scripts/raw/branch/master/Tools.ps1'))) }
|
||||||
@@ -26,14 +23,25 @@ If ( $INSTALL ) {
|
|||||||
|
|
||||||
# Uninstall if $FORCE is true
|
# Uninstall if $FORCE is true
|
||||||
If ( $PreviousInstall ) {
|
If ( $PreviousInstall ) {
|
||||||
|
# Get previous AccountID, AgentID, CompanyID, and IntegratorID for use when reinstalling
|
||||||
|
LogMsg "Getting information from existing installation"
|
||||||
|
$ACCOUNT_ID = (Get-ItemPropertyValue -Path 'HKLM:SOFTWARE\ATERA Networks\AlphaAgent' -Name 'AccountId' -ErrorAction SilentlyContinue)
|
||||||
|
$AGENT_ID = (Get-ItemPropertyValue -Path 'HKLM:SOFTWARE\ATERA Networks\AlphaAgent' -Name 'AgentId' -ErrorAction SilentlyContinue)
|
||||||
|
$CUSTOMER_ID = (Get-ItemPropertyValue -Path 'HKLM:SOFTWARE\ATERA Networks\AlphaAgent' -Name 'CompanyId' -ErrorAction SilentlyContinue)
|
||||||
|
$INTEGRATOR_ID = (Get-ItemPropertyValue -Path 'HKLM:SOFTWARE\ATERA Networks\AlphaAgent' -Name 'IntegratorLogin' -ErrorAction SilentlyContinue)
|
||||||
|
|
||||||
LogMsg "Uninstalling previously installed agent"
|
LogMsg "Uninstalling previously installed agent"
|
||||||
$UninstallScript = Download-File -URL 'https://dev.emberkom.com/emberkom/management-scripts/raw/branch/master/Uninstall-AteraAgent.bat'
|
Run-Script -LivePSScript Uninstall-AteraAgent
|
||||||
Try { Start-Process "cmd.exe" -ArgumentList "/c ""${UninstallScript}""" -Wait }
|
# $UninstallScript = Download-File -URL 'https://dev.emberkom.com/emberkom/management-scripts/raw/branch/master/Uninstall-AteraAgent.ps1'
|
||||||
Catch { LogErr $_.Exception.Message }
|
# Try { Start-Process "powrshell.exe" -ArgumentList "-ExecutionPolicy Bypass -InputFormat None -NonInteractive -File ""${UninstallScript}""" -Wait }
|
||||||
Try { Remove-Item $UninstallScript -Force }
|
# Catch { LogErr $_.Exception.Message }
|
||||||
Catch { LogErr $_.Exception.Message }
|
# Try { Remove-Item $UninstallScript -Force }
|
||||||
|
# Catch { LogErr $_.Exception.Message }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Replace the '@' with '%40' - not sure why this is necessary, but it is
|
||||||
|
$INTEGRATOR_ID = $INTEGRATOR_ID.Replace('@','%40')
|
||||||
|
|
||||||
# Download agent installer
|
# Download agent installer
|
||||||
Download-File -URL "https://app.atera.com/GetAgent/Msi/?customerId=${CUSTOMER_ID}&integratorLogin=${INTEGRATOR_ID}" -File "${AGENT_INSTALLER}"
|
Download-File -URL "https://app.atera.com/GetAgent/Msi/?customerId=${CUSTOMER_ID}&integratorLogin=${INTEGRATOR_ID}" -File "${AGENT_INSTALLER}"
|
||||||
|
|
||||||
@@ -47,6 +55,17 @@ If ( $INSTALL ) {
|
|||||||
Try { Remove-Item $AGENT_INSTALLER -Force }
|
Try { Remove-Item $AGENT_INSTALLER -Force }
|
||||||
Catch { LogErr $_.Exception.Message }
|
Catch { LogErr $_.Exception.Message }
|
||||||
|
|
||||||
|
# Restore agent information from previous install
|
||||||
|
If ( $PreviousInstall ) {
|
||||||
|
LogMsg "Stopping AteraAgent service"
|
||||||
|
Stop-Service -Name 'AteraAgent' -Force
|
||||||
|
LogMsg "Restoring AgentID and AccountID from previous install"
|
||||||
|
Set-ItemProperty -Path 'HKLM:SOFTWARE\ATERA Networks\AlphaAgent' -Name 'AccountId' -Value $ACCOUNT_ID
|
||||||
|
Set-ItemProperty -Path 'HKLM:SOFTWARE\ATERA Networks\AlphaAgent' -Name 'AgentId' -Value $AGENT_ID
|
||||||
|
LogMsg "Starting AteraAgent service"
|
||||||
|
Start-Service -Name 'AteraAgent'
|
||||||
|
}
|
||||||
|
|
||||||
} Else { LogMsg "Atera agent is already installed on this endpoint." }
|
} Else { LogMsg "Atera agent is already installed on this endpoint." }
|
||||||
|
|
||||||
# Delete this script
|
# Delete this script
|
||||||
|
|||||||
@@ -62,39 +62,25 @@ New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT | Out-Null
|
|||||||
|
|
||||||
# Get MSI package codes from the uninstall key
|
# Get MSI package codes from the uninstall key
|
||||||
$UninstallCodes = New-Object System.Collections.ArrayList
|
$UninstallCodes = New-Object System.Collections.ArrayList
|
||||||
'AteraAgent', 'Splashtop for RMM', 'Splashtop Streamer' | ForEach-Object { Get-UninstallCodes -DisplayName $_ }
|
'AteraAgent' | ForEach-Object { Get-UninstallCodes -DisplayName $_ }
|
||||||
|
|
||||||
# Get product keys from the list of installed products
|
# Get product keys from the list of installed products
|
||||||
$ProductKeys = New-Object System.Collections.ArrayList
|
$ProductKeys = New-Object System.Collections.ArrayList
|
||||||
'AteraAgent', 'Splashtop for RMM', 'Splashtop Streamer' | ForEach-Object { Get-ProductKeys -ProductName $_ }
|
'AteraAgent' | ForEach-Object { Get-ProductKeys -ProductName $_ }
|
||||||
|
|
||||||
# Define all the directories we'll need to cleanup at the end of this script
|
# Define all the directories we'll need to cleanup at the end of this script
|
||||||
$Directories = @(
|
$Directories = @("${Env:ProgramFiles}\ATERA Networks")
|
||||||
"${Env:ProgramFiles}\ATERA Networks",
|
|
||||||
"${Env:ProgramFiles}\Splashtop\Splashtop Remote\Server",
|
|
||||||
"${Env:ProgramFiles(x86)}\Splashtop\Splashtop Remote\Server",
|
|
||||||
"${Env:ProgramFiles}\Splashtop\Splashtop Software Updater",
|
|
||||||
"${Env:ProgramFiles(x86)}\Splashtop\Splashtop Software Updater",
|
|
||||||
"${Env:ProgramData}\Splashtop\Splashtop Software Updater"
|
|
||||||
)
|
|
||||||
|
|
||||||
# Get all possible relevant exe files so we can make sure they're closed later on
|
# Get all possible relevant exe files so we can make sure they're closed later on
|
||||||
$ExeFiles = New-Object System.Collections.ArrayList
|
$ExeFiles = New-Object System.Collections.ArrayList
|
||||||
"${Env:ProgramFiles}\ATERA Networks" | ForEach-Object { Get-AllExeFiles -Path $_ }
|
$Directories | ForEach-Object { Get-AllExeFiles -Path $_ }
|
||||||
|
$ExeFiles.Add('reg') | Out-Null
|
||||||
|
|
||||||
# Define a list of services we need to stop and delete (if necessary)
|
# Define a list of services we need to stop and delete (if necessary)
|
||||||
$ServiceList = @(
|
$ServiceList = @('AteraAgent')
|
||||||
'AteraAgent',
|
|
||||||
'SplashtopRemoteService',
|
|
||||||
'SSUService'
|
|
||||||
)
|
|
||||||
|
|
||||||
# Define a list of registry keys we'll delete
|
# Define a list of registry keys we'll delete
|
||||||
$RegistryKeys = @(
|
$RegistryKeys = @('HKLM:SOFTWARE\ATERA Networks')
|
||||||
'HKLM:SOFTWARE\ATERA Networks',
|
|
||||||
'HKLM:SOFTWARE\Splashtop Inc.',
|
|
||||||
'HKLM:SOFTWARE\WOW6432Node\Splashtop Inc.'
|
|
||||||
)
|
|
||||||
|
|
||||||
#######
|
#######
|
||||||
# END: Information gathering
|
# END: Information gathering
|
||||||
@@ -107,7 +93,6 @@ $UninstallCodes | ForEach-Object { Write-Output "Uninstall: ${_}" ; Start-Proces
|
|||||||
$ServiceList | ForEach-Object { Stop-RunningService -Name $_ }
|
$ServiceList | ForEach-Object { Stop-RunningService -Name $_ }
|
||||||
|
|
||||||
# Terminate all relevant processes that may still be running
|
# Terminate all relevant processes that may still be running
|
||||||
$ExeFiles.Add('reg') | Out-Null
|
|
||||||
$ExeFiles | ForEach-Object { Stop-RunningProcess $_ }
|
$ExeFiles | ForEach-Object { Stop-RunningProcess $_ }
|
||||||
|
|
||||||
# Delete services if they're still present
|
# Delete services if they're still present
|
||||||
@@ -124,8 +109,3 @@ $RegistryKeys | ForEach-Object { Remove-Path -Path $_ }
|
|||||||
|
|
||||||
# Delete remaining directories
|
# Delete remaining directories
|
||||||
$Directories | ForEach-Object { Remove-Path -Path $_ }
|
$Directories | ForEach-Object { Remove-Path -Path $_ }
|
||||||
|
|
||||||
# Atera's original script also deleted the following directories and registry keys
|
|
||||||
# However, since they are user specific and this script needs to run with admin credentials, I've left them commented out
|
|
||||||
# If you want to include them, just uncomment the line below:
|
|
||||||
#"${Env:LocalAppData}\Temp\TrayIconCaching", 'HKCU:SOFTWARE\ATERA Networks' | ForEach-Object { Remove-Path -Path $_ }
|
|
||||||
|
|||||||
Reference in New Issue
Block a user