Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
48c4abb60a | ||
|
|
589055732e | ||
|
|
a1a03c4c01 |
@@ -1,75 +0,0 @@
|
|||||||
param(
|
|
||||||
[Parameter(Mandatory=$false)][int]$CUSTOMER_ID=1,
|
|
||||||
[Parameter(Mandatory=$false)][string]$INTEGRATOR_ID,
|
|
||||||
[Parameter(Mandatory=$false)][string]$AGENT_FILENAME="AteraAgentSetup.msi",
|
|
||||||
[Parameter(Mandatory=$false)][switch]$FORCE
|
|
||||||
)
|
|
||||||
|
|
||||||
# Make sure $INTEGRATOR_ID exists, otherwise exit this script as an agent cannot be downloaded
|
|
||||||
#If ( ($INTEGRATOR_ID -eq $null) -or ($INTEGRATOR_ID -eq '') ) { Exit }
|
|
||||||
|
|
||||||
# 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 (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 ; Write-Output "Atera agent is already installed on this endpoint" } Else { $INSTALL = $true ; $PreviousInstall = $false }
|
|
||||||
|
|
||||||
If ( $FORCE ) { $INSTALL = $true }
|
|
||||||
|
|
||||||
If ( $INSTALL ) {
|
|
||||||
|
|
||||||
# Uninstall if $FORCE is true
|
|
||||||
If ( $PreviousInstall ) {
|
|
||||||
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)
|
|
||||||
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'
|
|
||||||
Try { Start-Process "powershell.exe" -ArgumentList "-ExecutionPolicy Bypass -Noninteractive -File ""${UninstallScript}""" -Wait }
|
|
||||||
Catch { Write-Error $_.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-File -URL "https://app.atera.com/GetAgent/Msi/?customerId=${CUSTOMER_ID}&integratorLogin=${INTEGRATOR_ID}" -File "${AGENT_INSTALLER}"
|
|
||||||
|
|
||||||
# Install the agent
|
|
||||||
Write-Output "Installing Atera agent from ""${AGENT_INSTALLER}"""
|
|
||||||
Try { Start-Process "msiexec.exe" -ArgumentList "/i ""${AGENT_INSTALLER}"" /qn /norestart" -Wait }
|
|
||||||
Catch { Write-Error $_.Exception.Message }
|
|
||||||
|
|
||||||
# Delete the agent installer
|
|
||||||
Write-Output "Deleting ""${AGENT_INSTALLER}"""
|
|
||||||
Try { Remove-Item $AGENT_INSTALLER -Force }
|
|
||||||
Catch { Write-Error $_.Exception.Message }
|
|
||||||
|
|
||||||
If ( $PreviousInstall -and $ACCOUNT_ID -and $AGENT_ID -and $CUSTOMER_ID) {
|
|
||||||
Write-Output "Restoring agent information from previous install"
|
|
||||||
Write-Output " - Stopping AteraAgent service"
|
|
||||||
Stop-Service -Name 'AteraAgent' -Force
|
|
||||||
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
|
|
||||||
Write-Output " - Starting AteraAgent service"
|
|
||||||
Start-Service -Name 'AteraAgent'
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
# Delete this script
|
|
||||||
Remove-Item $MyInvocation.MyCommand.Path -Force
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
param(
|
|
||||||
[Parameter(Mandatory=$true)][string]$TOKEN,
|
|
||||||
[Parameter(Mandatory=$true)][int]$CUSTOMER_ID,
|
|
||||||
[Parameter(Mandatory=$false)][int]$SOFTWARE_ID=101,
|
|
||||||
[Parameter(Mandatory=$false)][string]$SERVER='manage.emberkom.com',
|
|
||||||
[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 (Get-TempPath), $AGENT_FILENAME
|
|
||||||
|
|
||||||
## Get the right path to agent.exe based on the system bit-level
|
|
||||||
If ( Is64bit ) { $AGENT_EXE = "${Env:ProgramFiles(x86)}\N-able Technologies\Windows Agent\bin\agent.exe" }
|
|
||||||
Else { $AGENT_EXE = "${Env:ProgramFiles}\N-able Technologies\Windows Agent\bin\agent.exe" }
|
|
||||||
|
|
||||||
## Make sure we need to install the agent
|
|
||||||
If ( !(Test-Path $AGENT_EXE) )
|
|
||||||
{
|
|
||||||
## Download agent and get path
|
|
||||||
$AGENT_INSTALLER = Download-File -URL 'https://manage.emberkom.com/download/2020.1.5.425/winnt/N-central/WindowsAgentSetup.exe' -File $AGENT_INSTALLER
|
|
||||||
|
|
||||||
## Install the agent
|
|
||||||
Install-Program $AGENT_INSTALLER -Arguments "/s /v"" /qn CUSTOMERID=${CUSTOMER_ID} CUSTOMERSPECIFIC=1 REGISTRATION_TOKEN=${TOKEN} SERVERPROTOCOL=HTTPS SERVERADDRESS=${SERVER} SERVERPORT=443""" -Delete
|
|
||||||
|
|
||||||
} Else { Write-Output "N-Central agent is already installed on this endpoint." }
|
|
||||||
|
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
$URL = 'https://download.sketchup.com/SketchUpStudio-2023-1-340-117.exe'
|
$URL = 'https://download.sketchup.com/SketchUpStudio-2023-1-340-117.exe'
|
||||||
|
|
||||||
# TODO: Uninstall all versions of SketchUp
|
# TODO: Uninstall all versions of SketchUp
|
||||||
#'SketchUp 2019', 'SketchUp 2021', 'SketchUp 2022', 'SketchUp 2023', 'SketchUp Viewer' | Uninstall-MSI
|
#'SketchUp 2019', 'SketchUp 2020', 'SketchUp 2021', 'SketchUp 2022', 'SketchUp 2023', 'SketchUp Viewer' | Uninstall-MSI
|
||||||
|
|
||||||
# Set the local file name to download to
|
# Set the local file name to download to
|
||||||
$FILE = '{0}{1}' -f (Get-TempPath),(Split-Path $URL -Leaf)
|
$FILE = '{0}{1}' -f (Get-TempPath),(Split-Path $URL -Leaf)
|
||||||
|
|||||||
@@ -1,31 +0,0 @@
|
|||||||
param(
|
|
||||||
[Parameter(Mandatory=$true)][string]$URL,
|
|
||||||
[Parameter(Mandatory=$false)][string]$AGENT_FILENAME="SyncroInstaller.msi",
|
|
||||||
[Parameter(Mandatory=$false)][switch]$FORCE=$false
|
|
||||||
)
|
|
||||||
|
|
||||||
# Delete this script
|
|
||||||
Remove-Item $MyInvocation.MyCommand.Path -Force
|
|
||||||
|
|
||||||
# Exit early if we don't need to install the agent
|
|
||||||
If ( ($FORCE -eq $false) -and ((Test-Path "${Env:ProgramFiles}\RepairTech\Syncro\Syncro.App.Runner.exe") -or (Test-Path "${Env:ProgramFiles(x86)}\RepairTech\Syncro\Syncro.App.Runner.exe")) ) { Exit }
|
|
||||||
|
|
||||||
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 (Get-TempPath), $AGENT_FILENAME
|
|
||||||
|
|
||||||
# Download agent installer
|
|
||||||
Download-File -URL $URL -File "${AGENT_INSTALLER}"
|
|
||||||
|
|
||||||
# Install the agent
|
|
||||||
Write-Output "Installing Syncro agent from ""${AGENT_INSTALLER}"""
|
|
||||||
Try { Start-Process "msiexec.exe" -ArgumentList "/i ""${AGENT_INSTALLER}"" /qn /norestart" -Wait }
|
|
||||||
Catch { Write-Error $_.Exception.Message }
|
|
||||||
|
|
||||||
# Delete the agent installer
|
|
||||||
Write-Output "Deleting ""${AGENT_INSTALLER}"""
|
|
||||||
Try { Remove-Item $AGENT_INSTALLER -Force }
|
|
||||||
Catch { Write-Error $_.Exception.Message }
|
|
||||||
@@ -892,14 +892,19 @@ Function Get-GUIDFromMSIUninstallString ([string]$str) {
|
|||||||
Return $retval
|
Return $retval
|
||||||
}
|
}
|
||||||
|
|
||||||
Function Uninstall-MSI ([Parameter(ValueFromPipeline=$true)][string[]]$APP_NAMES) {
|
Function Uninstall-MSI {
|
||||||
PROCESS {
|
param(
|
||||||
|
[Parameter(ValueFromPipeline=$true,Mandatory=$true)][string[]]$APP_NAMES,
|
||||||
|
[Parameter(ValueFromPipeline=$false,Mandatory=$false)][switch]$Match,
|
||||||
|
[Parameter(ValueFromPipeline=$false,Mandatory=$false)][switch]$IncludeNonMSI
|
||||||
|
)
|
||||||
|
BEGIN {
|
||||||
# Get all of the uninstall registry keys
|
# Get all of the uninstall registry keys
|
||||||
$UNINSTALL_KEYS = Get-ChildItem -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall -ErrorAction SilentlyContinue
|
$UNINSTALL_KEYS = Get-ChildItem -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall -ErrorAction SilentlyContinue
|
||||||
$UNINSTALL_KEYS += Get-ChildItem -Path HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall -ErrorAction SilentlyContinue
|
$UNINSTALL_KEYS += Get-ChildItem -Path HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall -ErrorAction SilentlyContinue
|
||||||
|
|
||||||
# Exit if we can't find any software at all
|
# Exit if we can't find any software at all
|
||||||
If ( $UNINSTALL_KEYS.Length -eq 0 ) { Write-Error "Attempted to uninstall ${APP_NAMES} but could not find any installed apps in the Windows Registry" ; Return }
|
If ( $UNINSTALL_KEYS.Length -eq 0 ) { Write-Error "Could not find any installed apps in the Windows Registry" ; Return }
|
||||||
|
|
||||||
# Array to store custom objects about each installed MSI app
|
# Array to store custom objects about each installed MSI app
|
||||||
$INSTALLED_APPS = @()
|
$INSTALLED_APPS = @()
|
||||||
@@ -908,39 +913,52 @@ Function Uninstall-MSI ([Parameter(ValueFromPipeline=$true)][string[]]$APP_NAMES
|
|||||||
# Get the uninstall key
|
# Get the uninstall key
|
||||||
$REG_PROPERTY = Get-ItemProperty -Path $reg.PSPath
|
$REG_PROPERTY = Get-ItemProperty -Path $reg.PSPath
|
||||||
|
|
||||||
# Guards to prevent working with incompatible apps
|
# Skip apps missing both the UninstallString and ModifyPath
|
||||||
If ( [string]::IsNullOrEmpty($REG_PROPERTY.UninstallString) -and [string]::IsNullOrEmpty($REG_PROPERTY.ModifyPath) ) { Continue }
|
If ( [string]::IsNullOrEmpty($REG_PROPERTY.UninstallString) -and [string]::IsNullOrEmpty($REG_PROPERTY.ModifyPath) ) { Continue }
|
||||||
|
|
||||||
# Determine if the app is installed via MSI
|
# Determine if the app is installed via MSI
|
||||||
If ( $REG_PROPERTY.WindowsInstaller -eq 1 ) { $UNINSTALL_SUPPORTED = $true } Else { $UNINSTALL_SUPPORTED = $false }
|
If ( $REG_PROPERTY.WindowsInstaller -eq 1 ) {
|
||||||
|
|
||||||
|
$MSI = $true
|
||||||
|
|
||||||
# Get the product code from the UninstallString or ModifyPath if the app is installed via MSI
|
# Get the product code from the UninstallString or ModifyPath if the app is installed via MSI
|
||||||
[string]$PRODUCT_CODE = $null
|
If ( ![string]::IsNullOrEmpty($REG_PROPERTY.UninstallString) ) { $PRODUCT_CODE = $(Get-GUIDFromMSIUninstallString -str $REG_PROPERTY.UninstallString) }
|
||||||
If ( ![string]::IsNullOrEmpty($REG_PROPERTY.UninstallString) -and $UNINSTALL_SUPPORTED ) { $PRODUCT_CODE = $(Get-GUIDFromMSIUninstallString -str $REG_PROPERTY.UninstallString) }
|
|
||||||
|
|
||||||
# Get the product code from the ModifyPath
|
# Get the product code from the ModifyPath
|
||||||
ElseIf ( ![string]::IsNullOrEmpty($REG_PROPERTY.ModifyPath) -and $UNINSTALL_SUPPORTED ) { $PRODUCT_CODE = $(Get-GUIDFromMSIUninstallString -str $REG_PROPERTY.ModifyPath) }
|
ElseIf ( ![string]::IsNullOrEmpty($REG_PROPERTY.ModifyPath) ) { $PRODUCT_CODE = $(Get-GUIDFromMSIUninstallString -str $REG_PROPERTY.ModifyPath) }
|
||||||
|
|
||||||
# Additional guard to prevent adding an app with no product code
|
# Don't add an app with an unknown product code
|
||||||
If ( [string]::IsNullOrEmpty($PRODUCT_CODE) ) { Continue }
|
If ( [string]::IsNullOrEmpty($PRODUCT_CODE) ) { Continue }
|
||||||
|
|
||||||
|
} Else { $MSI = $false }
|
||||||
|
|
||||||
|
# Get a usable name for the entry
|
||||||
|
If ( $REG_PROPERTY.DisplayName)
|
||||||
|
|
||||||
$customObject = [PSCustomObject]@{
|
$customObject = [PSCustomObject]@{
|
||||||
UninstallSupported = $UNINSTALL_SUPPORTED
|
MSI = $MSI
|
||||||
DisplayName = $REG_PROPERTY.DisplayName
|
DisplayName = $REG_PROPERTY.DisplayName
|
||||||
UninstallString = $REG_PROPERTY.UninstallString
|
UninstallString = $REG_PROPERTY.UninstallString
|
||||||
ModifyPath = $REG_PROPERTY.ModifyPath
|
ModifyPath = $REG_PROPERTY.ModifyPath
|
||||||
ProductCode = $PRODUCT_CODE
|
ProductCode = $PRODUCT_CODE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Cleanup object properties
|
||||||
|
If ( $customObject.)
|
||||||
|
|
||||||
$INSTALLED_APPS += $customObject
|
$INSTALLED_APPS += $customObject
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
PROCESS {
|
||||||
Foreach ( $app in $APP_NAMES ) {
|
Foreach ( $app in $APP_NAMES ) {
|
||||||
Foreach ( $installed_app in $INSTALLED_APPS ) {
|
Foreach ( $installed_app in $INSTALLED_APPS ) {
|
||||||
|
|
||||||
# Make sure the DisplayName matches what we're looking for
|
# Do not add apps which name does not match the one we're looking for
|
||||||
If ( !($installed_app.DisplayName -ilike $app) ) { Continue }
|
Switch ( $Match ) {
|
||||||
|
$true { If ( !($installed_app.DisplayName -match $app) ) { Continue } }
|
||||||
|
$false { If ( !($installed_app.DisplayName -ilike $app) ) { Continue } }
|
||||||
|
}
|
||||||
|
|
||||||
$DisplayName = $installed_app.DisplayName
|
$DisplayName = $installed_app.DisplayName
|
||||||
$UninstallString = $installed_app.UninstallString
|
$UninstallString = $installed_app.UninstallString
|
||||||
|
|||||||
Reference in New Issue
Block a user