@@ -11,32 +11,44 @@ Set-StrictMode -Version Latest
1111$folder = " WslLogs-" + (Get-Date - Format " yyyy-MM-dd_HH-mm-ss" )
1212mkdir - p $folder | Out-Null
1313
14- if ($LogProfile -eq $null -Or ! [System.IO.File ]::Exists($LogProfile ))
14+ # Check if LogProfile is a custom file path or a profile name
15+ if ($LogProfile -ne $null -And [System.IO.File ]::Exists($LogProfile ))
1516{
16- if ($LogProfile -eq $null )
17+ # User provided a custom .wprp file path - use it directly
18+ $wprpFile = $LogProfile
19+ $wprpProfile = $null # Use default profile in the file
20+ }
21+ else
22+ {
23+ # Map log profile names to WPRP profile names
24+ $wprpProfile = " WSL"
25+ if ($LogProfile -eq " storage" )
1726 {
18- $url = " https://raw.githubusercontent.com/microsoft/ WSL/master/diagnostics/wsl.wprp "
27+ $wprpProfile = " WSL-Storage "
1928 }
20- elseif ($LogProfile -eq " storage " )
29+ elseif ($LogProfile -eq " networking " )
2130 {
22- $url = " https://raw.githubusercontent.com/microsoft/ WSL/master/diagnostics/wsl_storage.wprp "
31+ $wprpProfile = " WSL-Networking "
2332 }
2433 elseif ($LogProfile -eq " hvsocket" )
2534 {
26- $url = " https://raw.githubusercontent.com/microsoft/ WSL/master/diagnostics/wsl_hvsocket.wprp "
35+ $wprpProfile = " WSL-HvSocket "
2736 }
28- else
37+ elseif ( $LogProfile -ne $null )
2938 {
30- Write-Error " Unknown log profile: $LogProfile "
39+ Write-Error " Unknown log profile: $LogProfile . Valid options are: storage, networking, hvsocket, or a path to a custom .wprp file "
3140 exit 1
3241 }
3342
34- $LogProfile = " $folder /wsl.wprp"
35- try {
36- Invoke-WebRequest - UseBasicParsing $url - OutFile $LogProfile
43+ # Use the consolidated wsl.wprp file, attempt to use local copy first.
44+ $wprpFile = " $folder /wsl.wprp"
45+ if (Test-Path " $PSScriptRoot /wsl.wprp" )
46+ {
47+ Copy-Item " $PSScriptRoot /wsl.wprp" $wprpFile
3748 }
38- catch {
39- throw
49+ else
50+ {
51+ Invoke-WebRequest - UseBasicParsing " https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/wsl.wprp" - OutFile $wprpFile
4052 }
4153}
4254
@@ -71,13 +83,23 @@ if (Test-Path $uninstallLogs)
7183
7284$wprOutputLog = " $folder /wpr.txt"
7385
74- wpr.exe - start $LogProfile - filemode 2>&1 >> $wprOutputLog
86+ # Build wpr command - if wprpProfile is set, use profile syntax, otherwise use file only
87+ if ($wprpProfile -ne $null )
88+ {
89+ $wprCommand = " $wprpFile !$wprpProfile "
90+ }
91+ else
92+ {
93+ $wprCommand = $wprpFile
94+ }
95+
96+ wpr.exe - start $wprCommand - filemode 2>&1 >> $wprOutputLog
7597if ($LastExitCode -Ne 0 )
7698{
7799 Write-Host - ForegroundColor Yellow " Log collection failed to start (exit code: $LastExitCode ), trying to reset it."
78100 wpr.exe - cancel 2>&1 >> $wprOutputLog
79101
80- wpr.exe - start $LogProfile - filemode 2>&1 >> $wprOutputLog
102+ wpr.exe - start $wprCommand - filemode 2>&1 >> $wprOutputLog
81103 if ($LastExitCode -Ne 0 )
82104 {
83105 Write-Host - ForegroundColor Red " Couldn't start log collection (exitCode: $LastExitCode )"
0 commit comments