improved agent installation detection
This commit is contained in:
+12
-10
@@ -1,4 +1,4 @@
|
||||
[CmdletBinding()]
|
||||
#[CmdletBinding()]
|
||||
param(
|
||||
[string]$TOKEN,
|
||||
[int]$CUSTOMER_ID,
|
||||
@@ -7,6 +7,11 @@ param(
|
||||
[string]$AGENT_FILENAME='EmberkomAgentSetup.exe'
|
||||
)
|
||||
|
||||
## Immediately delete this script from disk
|
||||
$THIS_SCRIPT = $MyInvocation.InvocationName
|
||||
Try { Remove-Item $MyInvocation.InvocationName -Force }
|
||||
Catch { Write-Output "This script tried to delete itself but failed!" }
|
||||
|
||||
## Get temporary path
|
||||
$TEMP = [System.IO.Path]::GetTempPath()
|
||||
|
||||
@@ -19,13 +24,6 @@ Function Write-Log([string]$message)
|
||||
Add-Content -Path $LOGFILE -Value $entry
|
||||
}
|
||||
Write-Log "Agent installation script has started"
|
||||
|
||||
## Immediately delete this script from disk
|
||||
$THIS_SCRIPT = $MyInvocation.InvocationName
|
||||
Write-Log "Deleting this script: ${THIS_SCRIPT}"
|
||||
Try { Remove-Item $MyInvocation.InvocationName -Force }
|
||||
Catch { Write-Log "This script tried to delete itself but failed!" }
|
||||
|
||||
Write-Log "CUSTOMER_ID: ${CUSTOMER_ID}"
|
||||
Write-Log "SOFTWARE_ID: ${SOFTWARE_ID}"
|
||||
|
||||
@@ -36,11 +34,15 @@ Write-Log "Agent installer will be saved to: ${AGENT_INSTALLER}"
|
||||
## Make sure the CUSTOMER_ID is specified
|
||||
If ( $CUSTOMER_ID -and $TOKEN )
|
||||
{
|
||||
## Get the right path to agent.exe based on the system bit-level
|
||||
If ( Test-Path "${Env:ProgramFiles(x86)}" )
|
||||
{ $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 'HKLM:SOFTWARE\N-able Technologies\NcentralAsset') -and !(Test-Path 'SOFTWARE\Wow6432Node\N-able Technologies\NcentralAsset'))
|
||||
If ( !(Test-Path $AGENT_EXE) )
|
||||
{
|
||||
## Build the AGENT_URL
|
||||
#$AGENT_URL = 'https://manage.emberkom.com/downloadAgentOrProbeSoftwareDownloadAction.action?customerId={0}&softwareId={1}' -f $CUSTOMER_ID.ToString(),$SOFTWARE_ID.ToString()
|
||||
$AGENT_URL = 'https://manage.emberkom.com/download/2020.1.0.202/winnt/N-central/WindowsAgentSetup.exe'
|
||||
|
||||
## Delete $AGENT_INSTALLER if it already exists
|
||||
|
||||
Reference in New Issue
Block a user