major update to override Write-Output func
This commit is contained in:
+12
-12
@@ -18,7 +18,7 @@ $AGENT_INSTALLER = '{0}{1}' -f (Get-TempPath), $AGENT_FILENAME
|
||||
|
||||
# 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") )
|
||||
{ $INSTALL = $false ; $PreviousInstall = $true ; LogMsg "Atera agent is already installed on this endpoint" } Else { $INSTALL = $true ; $PreviousInstall = $false }
|
||||
{ $INSTALL = $false ; $PreviousInstall = $true ; Write-Output "Atera agent is already installed on this endpoint" } Else { $INSTALL = $true ; $PreviousInstall = $false }
|
||||
|
||||
If ( $FORCE ) { $INSTALL = $true }
|
||||
|
||||
@@ -26,15 +26,15 @@ If ( $INSTALL ) {
|
||||
|
||||
# Uninstall if $FORCE is true
|
||||
If ( $PreviousInstall ) {
|
||||
LogMsg "Getting information from existing installation"
|
||||
Write-Output "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 "AccountID : ${ACCOUNT_ID}"
|
||||
LogMsg "AgentID : ${AGENT_ID}"
|
||||
LogMsg "CustomerID : ${CUSTOMER_ID}"
|
||||
LogMsg "IntegratorID: ${INTEGRATOR_ID}"
|
||||
Write-Output "AccountID : ${ACCOUNT_ID}"
|
||||
Write-Output "AgentID : ${AGENT_ID}"
|
||||
Write-Output "CustomerID : ${CUSTOMER_ID}"
|
||||
Write-Output "IntegratorID: ${INTEGRATOR_ID}"
|
||||
|
||||
#Download and run the uninstall script
|
||||
$UninstallScript = Download-File -URL 'https://dev.emberkom.com/emberkom/management-scripts/raw/branch/master/Uninstall-AteraAgent.ps1'
|
||||
@@ -49,23 +49,23 @@ If ( $INSTALL ) {
|
||||
Download-File -URL "https://app.atera.com/GetAgent/Msi/?customerId=${CUSTOMER_ID}&integratorLogin=${INTEGRATOR_ID}" -File "${AGENT_INSTALLER}"
|
||||
|
||||
# Install the agent
|
||||
LogMsg "Installing Atera agent from ""${AGENT_INSTALLER}"""
|
||||
Write-Output "Installing Atera 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}"""
|
||||
Write-Output "Deleting ""${AGENT_INSTALLER}"""
|
||||
Try { Remove-Item $AGENT_INSTALLER -Force }
|
||||
Catch { LogErr $_.Exception.Message }
|
||||
|
||||
If ( $PreviousInstall -and $ACCOUNT_ID -and $AGENT_ID -and $CUSTOMER_ID) {
|
||||
LogMsg "Restoring agent information from previous install"
|
||||
LogMsg " - Stopping AteraAgent service"
|
||||
Write-Output "Restoring agent information from previous install"
|
||||
Write-Output " - Stopping AteraAgent service"
|
||||
Stop-Service -Name 'AteraAgent' -Force
|
||||
LogMsg " - Restoring AgentID and AccountID from previous install"
|
||||
Write-Output " - 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"
|
||||
Write-Output " - Starting AteraAgent service"
|
||||
Start-Service -Name 'AteraAgent'
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user