# Script to install/update Nextcloud desktop client # Technolog Networks - 2025-10-18 # iRaven <# .SYNOPSIS Updates Nextcloud Client .PARAMETER Install Boolean to install the client if not installed #> Start-Transcript -Path "$env:systemdrive\irnh\Nextcloud-Updater.log" -Append $PkgInfo = Get-Package -Name "Nextcloud*" $LatestVer = (irm https://api.github.com/repos/nextcloud-releases/desktop/releases/latest).tag_name $LatestVerURL = (irm https://api.github.com/repos/nextcloud-releases/desktop/releases/latest).assets.browser_download_url -like "*.msi" Function IsLatestVer { if (($LatestVer.Substring(1)) -gt ($PkgInfo.Version.Substring(0,6))){ return $false } else { return $true } } Function DownloadLatestVer { try { if (!(Test-Path "$env:systemdrive\irnh\Nextcloud-$LatestVer.msi")) { cmd.exe /c "curl -L -o $env:systemdrive\irnh\Nextcloud-$LatestVer.msi $LatestVerURL" } } catch { write-host -ForegroundColor red "Couldn't download the latest installer at URL $LatestVerURL !" } } Function InstallLatestVer { try { Write-Host -ForegroundColor Yellow "Installing Nextcloud Client $LatestVer" $NCInstall = Start-Process msiexec -Wait -PassThru -ArgumentList "/passive /i $env:systemdrive\irnh\Nextcloud-$LatestVer.msi REBOOT=ReallySuppress" write-host "returned exit code" $NCInstall.ExitCode if (0 -in $NCInstall.ExitCode) { Write-Host -ForegroundColor Green "Successfully installed!" del "$env:SystemDrive\irnh\Nextcloud-$LatestVer.msi" } } catch { write-host "it no worky" } } if (!($PkgInfo) -and !($Install)) { # Not installed, no install flag Write-Host -ForegroundColor Yellow "Nextcloud not installed & not installing it." } elseif (!($PkgInfo) -and $Install) { # Not installed, with install flag Write-Host -ForegroundColor Yellow "Nextcloud not installed - installing latest version $LatestVer" DownloadLatestVer InstallLatestVer } else { Write-Host -ForegroundColor Yellow "Nextcloud installed with" $PkgInfo.Version if (IsLatestVer) { Write-Host -ForegroundColor Green "The currently installed version is the latest version" } else { Write-Host -ForegroundColor Yellow "The currently installed version is NOT the latest version - installing $LatestVer" DownloadLatestVer InstallLatestVer } } Write-Host "Exiting" Stop-Transcript