more verbose output
This commit is contained in:
+11
-15
@@ -18,7 +18,7 @@ $AGENT_INSTALLER = '{0}{1}' -f (GetTempPath), $AGENT_FILENAME
|
|||||||
|
|
||||||
# Make sure we need to install the agent
|
# Make sure we need to install the agent
|
||||||
If ( (Test-Path "${Env:ProgramFiles}\ATERA Networks\AteraAgent\AteraAgent.exe") -or (Test-Path "${Env:ProgramFiles(x86)}\ATERA Networks\AteraAgent\AteraAgent.exe") )
|
If ( (Test-Path "${Env:ProgramFiles}\ATERA Networks\AteraAgent\AteraAgent.exe") -or (Test-Path "${Env:ProgramFiles(x86)}\ATERA Networks\AteraAgent\AteraAgent.exe") )
|
||||||
{ $INSTALL = $false ; $PreviousInstall = $true } Else { $INSTALL = $true ; $PreviousInstall = $false }
|
{ $INSTALL = $false ; $PreviousInstall = $true ; LogMsg "Atera agent is already installed on this endpoint" } Else { $INSTALL = $true ; $PreviousInstall = $false }
|
||||||
|
|
||||||
If ( $FORCE ) { $INSTALL = $true }
|
If ( $FORCE ) { $INSTALL = $true }
|
||||||
|
|
||||||
@@ -26,20 +26,16 @@ 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"
|
LogMsg "Getting information from existing installation"
|
||||||
$ACCOUNT_ID = (Get-ItemPropertyValue -Path 'HKLM:SOFTWARE\ATERA Networks\AlphaAgent' -Name 'AccountId' -ErrorAction SilentlyContinue)
|
$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)
|
$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)
|
$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)
|
$INTEGRATOR_ID = (Get-ItemPropertyValue -Path 'HKLM:SOFTWARE\ATERA Networks\AlphaAgent' -Name 'IntegratorLogin' -ErrorAction SilentlyContinue)
|
||||||
|
LogMsg "AccountID : ${ACCOUNT_ID}"
|
||||||
LogMsg "Uninstalling previously installed agent"
|
LogMsg "AgentID : ${AGENT_ID}"
|
||||||
|
LogMsg "CustomerID : ${CUSTOMER_ID}"
|
||||||
|
LogMsg "IntegratorID: ${INTEGRATOR_ID}"
|
||||||
Run-Script -LivePSScript Uninstall-AteraAgent
|
Run-Script -LivePSScript Uninstall-AteraAgent
|
||||||
# $UninstallScript = Download-File -URL 'https://dev.emberkom.com/emberkom/management-scripts/raw/branch/master/Uninstall-AteraAgent.ps1'
|
|
||||||
# Try { Start-Process "powrshell.exe" -ArgumentList "-ExecutionPolicy Bypass -InputFormat None -NonInteractive -File ""${UninstallScript}""" -Wait }
|
|
||||||
# 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
|
# Replace the '@' with '%40' - not sure why this is necessary, but it is
|
||||||
@@ -58,18 +54,18 @@ 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 -and $ACCOUNT_ID -and $AGENT_ID -and $CUSTOMER_ID) {
|
||||||
If ( $PreviousInstall ) {
|
LogMsg "Restoring agent information from previous install"
|
||||||
LogMsg "Stopping AteraAgent service"
|
LogMsg " - Stopping AteraAgent service"
|
||||||
Stop-Service -Name 'AteraAgent' -Force
|
Stop-Service -Name 'AteraAgent' -Force
|
||||||
LogMsg "Restoring AgentID and AccountID from previous install"
|
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 'AccountId' -Value $ACCOUNT_ID
|
||||||
Set-ItemProperty -Path 'HKLM:SOFTWARE\ATERA Networks\AlphaAgent' -Name 'AgentId' -Value $AGENT_ID
|
Set-ItemProperty -Path 'HKLM:SOFTWARE\ATERA Networks\AlphaAgent' -Name 'AgentId' -Value $AGENT_ID
|
||||||
LogMsg "Starting AteraAgent service"
|
LogMsg " - Starting AteraAgent service"
|
||||||
Start-Service -Name 'AteraAgent'
|
Start-Service -Name 'AteraAgent'
|
||||||
}
|
}
|
||||||
|
|
||||||
} Else { LogMsg "Atera agent is already installed on this endpoint." }
|
}
|
||||||
|
|
||||||
# Delete this script
|
# Delete this script
|
||||||
Remove-Item $MyInvocation.MyCommand.Path -Force
|
Remove-Item $MyInvocation.MyCommand.Path -Force
|
||||||
|
|||||||
Reference in New Issue
Block a user