Update 8x8_Work_Updater.ps1

This commit is contained in:
2026-07-29 17:18:07 +01:00
parent 6c67d40cb2
commit d889236a99
+46 -9
View File
@@ -1,8 +1,8 @@
# ============================================================================== # ==============================================================================
# Script Name: 8x8_Work_Updater.ps1 # Script Name: 8x8_Work_Updater.ps1
# Description: Downloads 8x8, launches an interactive JCT600 GUI attached to # Description: Downloads 8x8 with console progress bar, launches interactive
# the active user's session via BUILTIN\Users, waits for response, # JCT600 GUI attached to user session via BUILTIN\Users, waits
# silently installs, relaunches 8x8 Work, and cleans up. # for response, silently installs, relaunches 8x8, and cleans up.
# ============================================================================== # ==============================================================================
# Ensure script is running elevated # Ensure script is running elevated
@@ -24,17 +24,56 @@ if (Test-Path $flagFile) { Remove-Item $flagFile -Force }
try { try {
# -------------------------------------------------------------------------- # --------------------------------------------------------------------------
# Step 1: Download 8x8 Setup Installer # Step 1: Download 8x8 Setup Installer with Console Progress Bar
# -------------------------------------------------------------------------- # --------------------------------------------------------------------------
$installerUrl = "https://work-desktop-assets.8x8.com/prod-publish/ga/work-64-msi-v8.35.2-6.msi" $installerUrl = "https://work-desktop-assets.8x8.com/prod-publish/ga/work-64-msi-v8.35.2-6.msi"
$installerPath = Join-Path $workDir "8x8_Work_Installer.msi" $installerPath = Join-Path $workDir "8x8_Work_Installer.msi"
Write-Host "[1/5] Downloading 8x8 Work installer..." -ForegroundColor Cyan Write-Host "[1/5] Downloading 8x8 Work installer..." -ForegroundColor Cyan
try { try {
Invoke-WebRequest -Uri $installerUrl -OutFile $installerPath -UseBasicParsing # Initialize .NET HttpClient
Write-Host "Download complete: $installerPath" -ForegroundColor Green $httpClient = New-Object System.Net.Http.HttpClient
$response = $httpClient.GetAsync($installerUrl, [System.Net.Http.HttpCompletionOption]::ResponseHeadersRead).Result
if (-not $response.IsSuccessStatusCode) {
throw "HTTP Error $($response.StatusCode)"
}
$totalBytes = $response.Content.Headers.ContentLength
$inputStream = $response.Content.ReadAsStreamAsync().Result
$outputStream = [System.IO.File]::Create($installerPath)
$buffer = New-Object byte[] 8192
$totalBytesRead = 0
$bytesRead = 0
# Stream copy loop with progress indicator
while (($bytesRead = $inputStream.Read($buffer, 0, $buffer.Length)) -gt 0) {
$outputStream.Write($buffer, 0, $bytesRead)
$totalBytesRead += $bytesRead
if ($totalBytes -gt 0) {
$percent = [math]::Round(($totalBytesRead / $totalBytes) * 100)
$downloadedMB = [math]::Round($totalBytesRead / 1MB, 2)
$totalMB = [math]::Round($totalBytes / 1MB, 2)
# Render ASCII progress bar
$barLength = 30
$filledLength = [math]::Round(($percent / 100) * $barLength)
$bar = ("" * $filledLength) + ("" * ($barLength - $filledLength))
Write-Host "`rDownloading: [$bar] $percent% ($downloadedMB MB / $totalMB MB)" -NoNewline -ForegroundColor Yellow
}
}
# Close Streams
$outputStream.Close()
$inputStream.Close()
$httpClient.Dispose()
Write-Host "`nDownload complete: $installerPath" -ForegroundColor Green
} catch { } catch {
Write-Error "Failed to download installer from $installerUrl. Error: $_" Write-Error "`nFailed to download installer from $installerUrl. Error: $_"
exit 1 exit 1
} }
@@ -153,8 +192,6 @@ $form.Dispose()
$taskName = "JCT600_8x8_Update_UserDialog" $taskName = "JCT600_8x8_Update_UserDialog"
$action = New-ScheduledTaskAction -Execute "powershell.exe" -Argument "-ExecutionPolicy Bypass -WindowStyle Hidden -File `"$guiScript`"" $action = New-ScheduledTaskAction -Execute "powershell.exe" -Argument "-ExecutionPolicy Bypass -WindowStyle Hidden -File `"$guiScript`""
# Use BUILTIN\Users group principal for Entra ID / Domain compatibility
$principal = New-ScheduledTaskPrincipal -GroupId "BUILTIN\Users" -RunLevel Limited $principal = New-ScheduledTaskPrincipal -GroupId "BUILTIN\Users" -RunLevel Limited
Register-ScheduledTask -TaskName $taskName -Action $action -Principal $principal -Force | Out-Null Register-ScheduledTask -TaskName $taskName -Action $action -Principal $principal -Force | Out-Null