diff --git a/diagnostics/collect-wsl-logs.ps1 b/diagnostics/collect-wsl-logs.ps1 index 139c3ba4c..5ebbab2b9 100644 --- a/diagnostics/collect-wsl-logs.ps1 +++ b/diagnostics/collect-wsl-logs.ps1 @@ -328,8 +328,28 @@ if ($Dump) } } -$logArchive = "$(Resolve-Path $folder).zip" -Compress-Archive -Path $folder -DestinationPath $logArchive -Remove-Item $folder -Recurse +$logArchive = "$(Resolve-Path $folder).tar.gz" +tar.exe -czf $logArchive $folder +if ($LASTEXITCODE -eq 0) +{ + Remove-Item $folder -Recurse + Write-Host -ForegroundColor Green "Logs saved in: $logArchive. Please attach that file to the GitHub issue." +} +else +{ + Remove-Item $logArchive -ErrorAction Ignore -Write-Host -ForegroundColor Green "Logs saved in: $logArchive. Please attach that file to the GitHub issue." + # Fall back to zip if tar fails (e.g. on SKUs that lack tar.exe) + $logArchive = "$(Resolve-Path $folder).zip" + try + { + Compress-Archive -Path $folder -DestinationPath $logArchive -Force + Remove-Item $folder -Recurse + Write-Host -ForegroundColor Green "Logs saved in: $logArchive. Please attach that file to the GitHub issue." + } + catch + { + Remove-Item $logArchive -ErrorAction Ignore + Write-Host -ForegroundColor Red "Failed to compress logs. They are available in: $(Resolve-Path $folder)" + } +}