Add a handy shortcut to collect storage logs (#11004)

Blue committed Jan 10, 2024 at 11:47 UTC 96bd92ee980701dfc9b633c0ecb8b30ecbd001cc
1 file changed +16 -2
diagnostics/collect-wsl-logs.ps1
+16 -2
@@ -11,11 +11,25 @@ Set-StrictMode -Version Latest
11 $folder = "WslLogs-" + (Get-Date -Format "yyyy-MM-dd_HH-mm-ss")
12 mkdir -p $folder | Out-Null
13
14 -if ($LogProfile -eq $null)
14 +if ($LogProfile -eq $null -Or ![System.IO.File]::Exists($LogProfile))
15 {
16 + if ($LogProfile -eq $null)
17 + {
18 + $url = "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/wsl.wprp"
19 + }
20 + elseif ($LogProfile -eq "storage")
21 + {
22 + $url = "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/wsl_storage.wprp"
23 + }
24 + else
25 + {
26 + Write-Error "Unknown log profile: $LogProfile"
27 + exit 1
28 + }
29 +
30 $LogProfile = "$folder/wsl.wprp"
31 try {
18 - Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/wsl.wprp" -OutFile $LogProfile
32 + Invoke-WebRequest -UseBasicParsing $url -OutFile $LogProfile
33 }
34 catch {
35 throw