update
This commit is contained in:
@@ -10,7 +10,7 @@ $TEMP = [System.IO.Path]::GetTempPath()
|
||||
|
||||
## Setup log file and function to write to it
|
||||
$LOGFILE = "{0}EmberkomAgentSetup_{1}.log" -f $TEMP, $(Get-Date -Format "yyyyMMddHHmmss")
|
||||
If (! (Test-Path $LOGFILE) ) { New-Item -Path $LOGFILE -ItemType File }
|
||||
If (! (Test-Path $LOGFILE) ) { New-Item -Path $LOGFILE -ItemType File | Out-Null; Write-Output "Log file: ${LOGFILE}" }
|
||||
Function Write-Log([string]$message)
|
||||
{
|
||||
$entry = "{0} : {1}" -f $(Get-Date -Format "yyyyMMddHHmmss"), $Message
|
||||
@@ -28,7 +28,7 @@ Write-Log "CUSTOMER_ID: ${CUSTOMER_ID}"
|
||||
Write-Log "SOFTWARE_ID: ${SOFTWARE_ID}"
|
||||
|
||||
## Build the path for $AGENT_INSTALLER
|
||||
$AGENT_INSTALLER = "${TEMP}\${AGENT_FILENAME}"
|
||||
$AGENT_INSTALLER = "${TEMP}${AGENT_FILENAME}"
|
||||
Write-Log "Agent installer will be saved to: ${AGENT_INSTALLER}"
|
||||
|
||||
## Make sure the CUSTOMER_ID is specified
|
||||
@@ -38,7 +38,8 @@ If ( $CUSTOMER_ID )
|
||||
If ( !(Test-Path 'HKLM:SOFTWARE\N-able Technologies\NcentralAsset') -and !(Test-Path 'SOFTWARE\Wow6432Node\N-able Technologies\NcentralAsset'))
|
||||
{
|
||||
## Build the AGENT_URL
|
||||
$AGENT_URL = "{0}{1}{2}{3}" -f 'https://manage.emberkom.com/dms/FileDownload?customerID=',$CUSTOMER_ID.ToString(),'&softwareID=',$SOFTWARE_ID.ToString()
|
||||
$AGENT_URL = 'https://manage.emberkom.com/downloadAgentOrProbeSoftwareDownloadAction.action?customerId={0}&softwareId={1}' -f $CUSTOMER_ID.ToString(),$SOFTWARE_ID.ToString()
|
||||
write-host $AGENT_URL
|
||||
|
||||
## Delete $AGENT_INSTALLER if it already exists
|
||||
If ( Test-Path $AGENT_INSTALLER )
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
## URL for Windows 10
|
||||
If ( ([System.Environment]::OSVersion.Version).Major -ge 10 )
|
||||
{ $URL = 'https://swupdate.openvpn.org/community/releases/openvpn-install-2.4.7-I607-Win10.exe' }
|
||||
|
||||
## URL for Windows 7
|
||||
ElseIf ( (([System.Environment]::OSVersion.Version).Major -ge 7) -and (([System.Environment]::OSVersion.Version).Major -lt 10) )
|
||||
{ $URL = 'https://swupdate.openvpn.org/community/releases/openvpn-install-2.4.7-I607-Win7.exe' }
|
||||
|
||||
## Set the local filename
|
||||
$FILE = '{0}\{1}' -f $Env:TEMP,(Split-Path $URL -Leaf)
|
||||
|
||||
## Remove previous package
|
||||
If ( Test-Path $FILE ) { Remove-Item -Path $FILE -Force | Out-Null}
|
||||
|
||||
## Download installer
|
||||
Write-Output "Downloading: ${URL}"
|
||||
Try { (New-Object System.Net.WebClient).DownloadFile($URL, $FILE) }
|
||||
Catch { Write-Output $_.Exception.Message }
|
||||
|
||||
## Install package
|
||||
Write-Output "Installing: ${FILE}"
|
||||
Try { Start-Process -FilePath $FILE -ArgumentList "/S" -Wait }
|
||||
Catch { $_.Exception.Message }
|
||||
|
||||
## Delete installer package
|
||||
If ( Test-Path $FILE )
|
||||
{
|
||||
Write-Output "Deleting ${FILE}"
|
||||
Try { Remove-Item -Path $FILE -Force }
|
||||
Catch { Write-Output $_.Exception.Message }
|
||||
}
|
||||
Reference in New Issue
Block a user