updat
This commit is contained in:
@@ -1,23 +1,48 @@
|
|||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param(
|
param(
|
||||||
[string]$AGENT_URL,
|
[int]$CUSTOMER_ID,
|
||||||
|
[int]$SOFTWARE_ID=101,
|
||||||
[string]$AGENT_FILENAME='EmberkomAgentSetup.exe'
|
[string]$AGENT_FILENAME='EmberkomAgentSetup.exe'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
## Immediately delete this script from disk
|
||||||
|
Try { Remove-Item $MyINvocation.InvocationName -Force }
|
||||||
|
Catch { Write-Output "This script tried to delete itself but failed!" }
|
||||||
|
|
||||||
|
## Build the path for $AGENT_INSTALLER
|
||||||
$TEMP = [System.IO.Path]::GetTempPath()
|
$TEMP = [System.IO.Path]::GetTempPath()
|
||||||
$AGENT_INSTALLER = "${TEMP}\${AGENT_FILENAME}"
|
$AGENT_INSTALLER = "${TEMP}\${AGENT_FILENAME}"
|
||||||
|
|
||||||
## Make sure the AGENT_URL is specified
|
## Make sure the CUSTOMER_ID is specified
|
||||||
If ( $AGENT_URL )
|
If ( $CUSTOMER_ID )
|
||||||
{
|
{
|
||||||
## Make sure we need to install the agent
|
## 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 'HKLM:SOFTWARE\N-able Technologies\NcentralAsset') -and !(Test-Path 'SOFTWARE\Wow6432Node\N-able Technologies\NcentralAsset'))
|
||||||
{
|
{
|
||||||
## Download the agent
|
## Build the AGENT_URL
|
||||||
If ( Test-Path $AGENT_INSTALLER ) { Remove-Item $AGENT_INSTALLER -Force }
|
$AGENT_URL = "{0}{1}{2}{3}" -f 'https://manage.emberkom.com/dms/FileDownload?customerID=',$CUSTOMER_ID.ToString(),'&softwareID=',$SOFTWARE_ID.ToString()
|
||||||
(New-Object System.Net.WebClient).DownloadFile("${AGENT_URL}", $AGENT_INSTALLER)
|
|
||||||
|
## Delete $AGENT_INSTALLER if it already exists
|
||||||
|
If ( Test-Path $AGENT_INSTALLER )
|
||||||
|
{
|
||||||
|
Try { Remove-Item $AGENT_INSTALLER -Force }
|
||||||
|
Catch { Write-Output "The agent installer already exists but there was an error when trying to delete it!" }
|
||||||
|
}
|
||||||
|
|
||||||
|
## Download the agent installer
|
||||||
|
Try { (New-Object System.Net.WebClient).DownloadFile($AGENT_URL, $AGENT_INSTALLER) }
|
||||||
|
Catch { Write-Output "There was an error downloading the agent installer!"; Exit }
|
||||||
|
|
||||||
## Install the agent
|
## Install the agent
|
||||||
Start-Process $AGENT_INSTALLER -ArgumentList '/quiet /passive' -Wait
|
Try { Start-Process $AGENT_INSTALLER -ArgumentList '/quiet /passive' -Wait }
|
||||||
}
|
Catch { Write-Output "There was an error installing the agent!" }
|
||||||
}
|
New-Item -Path $Env:SYSTEMDRIVE -Name "ready-for-install" -ItemType "file" -Value ""
|
||||||
|
|
||||||
|
## Remove the agent installer
|
||||||
|
If ( Test-Path $AGENT_INSTALLER )
|
||||||
|
{
|
||||||
|
Try { Remove-Item -Path $AGENT_INSTALLER -Force }
|
||||||
|
Catch { Write-Output "There was an error while deleting the agent installer!" }
|
||||||
|
}
|
||||||
|
} Else { Write-Output "The agent is already installed on this endpoint." }
|
||||||
|
} Else { Write-Output "No CUSTOMER_ID was specified!" }
|
||||||
|
|||||||
Reference in New Issue
Block a user