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
+8 -26
View File
@@ -1,17 +1,12 @@
## Define URL for downloading the installer
$URL = 'https://dev.emberkom.com/emberkom/management-scripts/raw/branch/master/resources/Nextcloud-3.0.1-setup.exe'
$FILE = Split-Path $URL -Leaf
$FILE = '{0}{1}' -f (GetTempPath), (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 }
$FILE = Download-File -URL $URL -File $FILE
## Stop app if it's currently running
Get-Process | Where { $_.Name -like "nextcloud" } | Stop-Process -Force
Try { Get-Process | Where { $_.Name -like "nextcloud" } | Stop-Process -Force }
Catch { LogErr $_.Exception.Message }
## Get the install location so we can start the app again after installation
If ( Test-Path "HKLM:SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Nextcloud" )
@@ -20,25 +15,12 @@ ElseIf ( Test-Path "HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Nex
{ $InstallPath = '{0}\nextcloud.exe' -f $(Get-ItemProperty -Path "HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Nextcloud" -ErrorAction SilentlyContinue).InstallLocation }
## Install package
If ( Test-Path $FILE )
{
Write-Output "Installing: ${FILE}"
Try { Start-Process -FilePath $FILE -ArgumentList "/S" -Wait }
Catch { $_.Exception.Message }
}
Else { Write-Output "${FILE} does not exist" }
Install-Program -Path $FILE -Arguments "/S" -Delete
## Start the app after installation
If ( Test-Path $InstallPath )
{
Write-Output "Starting Nextcloud"
Start-Process $InstallPath
}
## Delete installer package
If ( Test-Path $FILE )
{
Write-Output "Deleting ${FILE}"
Try { Remove-Item -Path $FILE -Force }
Catch { Write-Output $_.Exception.Message }
LogMsg "Starting Nextcloud"
Try { Start-Process $InstallPath }
Catch { LogErr $_.Exception.Message }
}