From 38d8302e6dbb83c890e2eba2c2241757bd4a4620 Mon Sep 17 00:00:00 2001 From: dyoder Date: Fri, 4 Sep 2020 09:14:24 -0400 Subject: [PATCH] update --- Install-ManagementAgent.ps1 | 7 ++++--- Install-OpenVPN.ps1 | 31 +++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 Install-OpenVPN.ps1 diff --git a/Install-ManagementAgent.ps1 b/Install-ManagementAgent.ps1 index cee914e..6479ff2 100644 --- a/Install-ManagementAgent.ps1 +++ b/Install-ManagementAgent.ps1 @@ -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 ) diff --git a/Install-OpenVPN.ps1 b/Install-OpenVPN.ps1 new file mode 100644 index 0000000..8723f11 --- /dev/null +++ b/Install-OpenVPN.ps1 @@ -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 } +}