Skip to content

Instantly share code, notes, and snippets.

@graffhyrum
Created October 13, 2025 13:52
Show Gist options
  • Select an option

  • Save graffhyrum/f24132d80810494ee59a3882b6b26491 to your computer and use it in GitHub Desktop.

Select an option

Save graffhyrum/f24132d80810494ee59a3882b6b26491 to your computer and use it in GitHub Desktop.
From an admin powershell, silently update all packages installed with Winget. Also writes a log to the Desktop of the user.
# Check if winget is installed
try {
$winget = Get-Command winget -ErrorAction Stop
Write-Host "Winget is installed, proceeding with updates..." -ForegroundColor Green
} catch {
Write-Host "Winget is not installed. Please install winget first." -ForegroundColor Red
exit 1
}
# Create a log file with date stamp
$logFile = "winget_update_log_$(Get-Date -Format 'yyyy-MM-dd_HH-mm').txt"
$logDirPath = Join-Path $env:USERPROFILE "Desktop\.UpdateWingetScrptLogsLogs"
New-Item -ItemType Directory -Force -Path $logDirPath
$logPath = Join-Path $logDirPath $logFile
# Start transcript for logging
Start-Transcript -Path $logPath
try {
Write-Host "Starting silent update of all programs..." -ForegroundColor Yellow
# Run winget upgrade with all necessary silent parameters
winget upgrade --all --silent --accept-source-agreements --accept-package-agreements
Write-Host "Updates completed successfully!" -ForegroundColor Green
} catch {
Write-Host "An error occurred during the update process: $_" -ForegroundColor Red
} finally {
# Stop transcript
Stop-Transcript
}
# Optional: Display the log file
Get-Content $logPath | Select-Object -Last 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment