major logging overhaul, plus other fixes

This commit is contained in:
2020-10-22 14:01:35 -04:00
parent 77cf4d6276
commit 978373ebe2
27 changed files with 430 additions and 611 deletions
+20 -28
View File
@@ -1,31 +1,23 @@
## 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' }
$OpenVPNVersion = "2.4.7"
## 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' }
## Make sure we have an administrative token
If ( IsAdmin )
{
## URL for Windows 10
If ( IsWindowsVersion -ge "10.0" )
{ $URL = "https://swupdate.openvpn.org/community/releases/openvpn-install-${OpenVPNVersion}-I607-Win10.exe" }
## URL for Windows 7
ElseIf ( (IsWindowsVersion -ge "7.0") -and (IsWindowsVersion -lt "10.0") )
{ $URL = "https://swupdate.openvpn.org/community/releases/openvpn-install-${OpenVPNVersion}-I607-Win7.exe" }
## Set the local filename
$FILE = '{0}{1}' -f (GetTempPath),(Split-Path $URL -Leaf)
## Download installer
$FILE = Download-File -URL $URL -File $FILE
## 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 }
## Install package
Install-Program -Path $FILE -Arguments "/S" -Delete
}
Else { LogMsg "Must be an administrator to install OpenVPN" }