<# .SYNOPSIS Bundles the latest setup log and diagnostics into one zip, ready to send. Optionally uploads it to a pre-signed URL. .DESCRIPTION Two ways to get logs off this machine, in order of how likely they are to actually happen: 1. No arguments: makes one zip on the Desktop, selects it in Explorer and puts its path on the clipboard. Drag it into Discord. Works offline right up to the moment you send it, needs no credentials and no setup. 2. -UploadUrl : uploads it directly. The URL carries its own time-limited permission, so nothing on this machine holds any AWS credentials. Generate one with: aws s3 presign --method PUT --expires-in 86400 \ s3:///incoming/.zip --profile gaming .PARAMETER UploadUrl Pre-signed PUT URL. Omitted, the zip is just left on the Desktop. .PARAMETER Last How many diagnostics snapshots to include. Default 1. .EXAMPLE .\send-logs.ps1 .EXAMPLE .\send-logs.ps1 -UploadUrl "https://bucket.s3.amazonaws.com/incoming/abc.zip?X-Amz-..." #> [CmdletBinding()] param( [string]$UploadUrl, [int]$Last = 1 ) $ErrorActionPreference = "Stop" $diagRoot = "$env:USERPROFILE\Diagnostics" $stamp = Get-Date -Format "yyyy-MM-dd_HHmmss" $staging = Join-Path $env:TEMP "rig-logs-$stamp" $zipPath = Join-Path ([Environment]::GetFolderPath("Desktop")) "rig-logs-$stamp.zip" New-Item -Path $staging -ItemType Directory -Force | Out-Null Write-Host "" Write-Host "Collecting..." # --- setup transcripts --- $logs = @(Get-ChildItem $diagRoot -Filter "setup-*.log" -ErrorAction SilentlyContinue | Sort-Object LastWriteTime -Descending | Select-Object -First 3) if ($logs.Count -gt 0) { foreach ($l in $logs) { Copy-Item $l.FullName $staging } Write-Host " $($logs.Count) setup log(s)" } else { Write-Host " no setup logs found" } # --- most recent diagnostics snapshots --- $snaps = @(Get-ChildItem $diagRoot -Directory -ErrorAction SilentlyContinue | Sort-Object Name -Descending | Select-Object -First $Last) foreach ($snap in $snaps) { Copy-Item $snap.FullName (Join-Path $staging $snap.Name) -Recurse Write-Host " diagnostics: $($snap.Name)" } if ($logs.Count -eq 0 -and $snaps.Count -eq 0) { Write-Warning "Nothing to send. Run 'Collect Diagnostics' on the Desktop first." Remove-Item $staging -Recurse -Force -ErrorAction SilentlyContinue return } # --- one machine-summary file so context is not lost --- $os = Get-CimInstance Win32_OperatingSystem @" computer : $env:COMPUTERNAME user : $env:USERNAME os : $($os.Caption) build $($os.BuildNumber) gpu : $((Get-CimInstance Win32_VideoController | Select-Object -First 1).Name) zipped : $(Get-Date) "@ | Set-Content (Join-Path $staging "_about.txt") -Encoding UTF8 Compress-Archive -Path "$staging\*" -DestinationPath $zipPath -Force Remove-Item $staging -Recurse -Force -ErrorAction SilentlyContinue $sizeKb = [math]::Round((Get-Item $zipPath).Length / 1KB, 1) Write-Host "" Write-Host "Made: $zipPath ($sizeKb KB)" # --- upload, or hand it to a human --- if ($UploadUrl) { Write-Host "Uploading..." try { Invoke-RestMethod -Uri $UploadUrl -Method Put -InFile $zipPath ` -ContentType "application/zip" -ErrorAction Stop | Out-Null Write-Host "Uploaded." -ForegroundColor Green } catch { Write-Host "Upload failed: $($_.Exception.Message)" -ForegroundColor Yellow Write-Host "The zip is still on your Desktop -- send that instead." -ForegroundColor Yellow } } else { try { Set-Clipboard -Value $zipPath } catch {} Write-Host "" Write-Host "It is on your Desktop and the path is on your clipboard." Write-Host "Drag it into Discord and send it." Start-Process explorer.exe "/select,`"$zipPath`"" } Write-Host ""