@samitouri / QOSAMI-WSL / commits / b9b108c5

tracing: combine collect-wsl-logs.ps1 and collect-networking-logs.ps1 (#14089)

Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>

Ben Hillis committed Jan 22, 2026 at 11:18 UTC b9b108c548c28436b26b0ceb42bc0b7145ccbcd5
5 files changed +154 -327
.github/copilot-instructions.md
+1 -1
@@ -196,7 +196,7 @@ debugConsole=true
196 ### Common Debugging Commands
197 - Debug shell: `wsl --debug-shell`
198 - Collect WSL logs: `powershell diagnostics\collect-wsl-logs.ps1`
199 -- Network logs: `powershell diagnostics\collect-networking-logs.ps1`
199 +- Network logs: `powershell diagnostics\collect-wsl-logs.ps1 -LogProfile networking`
200
201 ## Critical Timing and Timeout Guidelines
202
CONTRIBUTING.md
+9 -4
@@ -53,13 +53,18 @@ Install [WPR](https://learn.microsoft.com/windows-hardware/test/wpt/windows-perf
53 To collect WSL networking logs, do the following steps in an administrative powershell prompt:
54
55 ```
56 -Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/collect-networking-logs.ps1" -OutFile collect-networking-logs.ps1
56 +Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/collect-wsl-logs.ps1" -OutFile collect-wsl-logs.ps1
57 Set-ExecutionPolicy Bypass -Scope Process -Force
58 -.\collect-networking-logs.ps1
58 +.\collect-wsl-logs.ps1 -LogProfile networking
59 ```
60 The script will output when log collection starts. Reproduce the problem, then press any key to stop the log collection.
61 The script will output the path of the log file once done.
62
63 +For additional network creation logs (restarts WSL), use:
64 +```
65 +.\collect-wsl-logs.ps1 -LogProfile networking -RestartWslReproMode
66 +```
67 +
68 <!-- Preserving anchors -->
69 <div id="8-detailed-logs"></div>
70 <div id="9-networking-logs"></div>
@@ -81,9 +86,9 @@ The script will output the path of the log file once done.
86
87 For specific scenarios, you can use different log profiles:
88 - `.\collect-wsl-logs.ps1 -LogProfile storage` - Enhanced storage tracing
84 -- `.\collect-wsl-logs.ps1 -LogProfile networking` - Networking-focused tracing
89 +- `.\collect-wsl-logs.ps1 -LogProfile networking` - Comprehensive networking tracing (includes packet capture, tcpdump, etc.)
90 +- `.\collect-wsl-logs.ps1 -LogProfile networking -RestartWslReproMode` - Networking tracing with WSL restart for network creation logs
91 - `.\collect-wsl-logs.ps1 -LogProfile hvsocket` - HvSocket-specific tracing
86 -- `.\collect-networking-logs.ps1` - Alternative script for networking tracing
92
93 ### 10) Reporting a Windows crash (BSOD)
94
diagnostics/collect-networking-logs.ps1 deleted
-320
@@ -1,320 +0,0 @@
1 -#Requires -RunAsAdministrator
2 -
3 -[CmdletBinding()]
4 -Param (
5 - $RestartWslReproMode = $false
6 - )
7 -
8 -function Collect-WindowsNetworkState {
9 -
10 - param (
11 - $ReproStep
12 - )
13 -
14 - # Collect host networking state relevant for WSL
15 - # Using a try/catch for commands below, as some of them do not exist on all OS versions
16 -
17 - try
18 - {
19 - Get-NetAdapter -includeHidden | select Name,ifIndex,NetLuid,InterfaceGuid,Status,MacAddress,MtuSize,InterfaceType,Hidden,HardwareInterface,ConnectorPresent,MediaType,PhysicalMediaType | Out-File -FilePath "$folder/Get-NetAdapter_$ReproStep.log" -Append
20 - }
21 - catch {}
22 -
23 - try
24 - {
25 - & netsh nlm query all $folder/nlmquery_"$ReproStep".log
26 - }
27 - catch {}
28 -
29 - try
30 - {
31 - Get-NetIPConfiguration -All -Detailed | Out-File -FilePath "$folder/Get-NetIPConfiguration_$ReproStep.log" -Append
32 - }
33 - catch {}
34 -
35 - try
36 - {
37 - Get-NetRoute | Out-File -FilePath "$folder/Get-NetRoute_$ReproStep.log" -Append
38 - }
39 - catch {}
40 -
41 - try
42 - {
43 - Get-NetFirewallHyperVVMCreator | Out-File -FilePath "$folder/Get-NetFirewallHyperVVMCreator_$ReproStep.log" -Append
44 - }
45 - catch {}
46 -
47 - try
48 - {
49 - Get-NetFirewallHyperVVMSetting -PolicyStore ActiveStore | Out-File -FilePath "$folder/Get-NetFirewallHyperVVMSetting_ActiveStore_$ReproStep.log" -Append
50 - }
51 - catch {}
52 -
53 - try
54 - {
55 - Get-NetFirewallHyperVProfile -PolicyStore ActiveStore | Out-File -FilePath "$folder/Get-NetFirewallHyperVProfile_ActiveStore_$ReproStep.log" -Append
56 - }
57 - catch {}
58 -
59 - try
60 - {
61 - Get-NetFirewallHyperVRule -PolicyStore ActiveStore | Out-File -FilePath "$folder/Get-NetFirewallHyperVRule_ActiveStore_$ReproStep.log" -Append
62 - }
63 - catch {}
64 -
65 - try
66 - {
67 - Get-NetFirewallRule -PolicyStore ActiveStore | Out-File -FilePath "$folder/Get-NetFirewallRule_ActiveStore_$ReproStep.log" -Append
68 - }
69 - catch {}
70 -
71 - try
72 - {
73 - Get-NetFirewallProfile -PolicyStore ActiveStore | Out-File -FilePath "$folder/Get-NetFirewallProfile_ActiveStore_$ReproStep.log" -Append
74 - }
75 - catch {}
76 -
77 - try
78 - {
79 - Get-NetFirewallHyperVPort | Out-File -FilePath "$folder/Get-NetFirewallHyperVPort_$ReproStep.log" -Append
80 - }
81 - catch {}
82 -
83 - try
84 - {
85 - & hnsdiag.exe list all 2>&1 > $folder/hnsdiag_list_all_"$ReproStep".log
86 - }
87 - catch {}
88 -
89 - try
90 - {
91 - & hnsdiag.exe list endpoints -df 2>&1 > $folder/hnsdiag_list_endpoints_"$ReproStep".log
92 - }
93 - catch {}
94 -
95 - try
96 - {
97 - foreach ($port in Get-NetFirewallHyperVPort)
98 - {
99 - & vfpctrl.exe /port $port.PortName /get-port-state 2>&1 > "$folder/vfp-port-$($port.PortName)-get-port-state_$ReproStep.log"
100 - & vfpctrl.exe /port $port.PortName /list-rule 2>&1 > "$folder/vfp-port-$($port.PortName)-list-rule_$ReproStep.log"
101 - }
102 - }
103 - catch {}
104 -
105 - try
106 - {
107 - & vfpctrl.exe /list-vmswitch-port 2>&1 > $folder/vfpctrl_list_vmswitch_port_"$ReproStep".log
108 - }
109 - catch {}
110 -
111 - try
112 - {
113 - Get-VMSwitch | select Name,Id,SwitchType | Out-File -FilePath "$folder/Get-VMSwitch_$ReproStep.log" -Append
114 - }
115 - catch {}
116 -
117 - try
118 - {
119 - Get-NetUdpEndpoint | Out-File -FilePath "$folder/Get-NetUdpEndpoint_$ReproStep.log" -Append
120 - }
121 - catch {}
122 -}
123 -
124 -$folder = "WslNetworkingLogs-" + (Get-Date -Format "yyyy-MM-dd_HH-mm-ss")
125 -mkdir -p $folder
126 -
127 -$wprpFile = "$folder/wsl.wprp"
128 -$wprpProfile = "WSL-Networking"
129 -$networkingBashScript = "$folder/networking.sh"
130 -
131 -# Detect the super user first.
132 -# Actually it's not definite that the super user is named "root". Instead, a user with uid=0 is what we are looking for. See #11693.
133 -$superUser = & wsl.exe -- id -nu 0 # user name of the super user.
134 -
135 -# Copy/Download supporting files
136 -if (Test-Path "$PSScriptRoot/wsl.wprp")
137 -{
138 - Copy-Item "$PSScriptRoot/wsl.wprp" $wprpFile
139 -}
140 -else
141 -{
142 - Write-Host -ForegroundColor Yellow "wsl.wprp not found in the current directory. Downloading it from GitHub."
143 - Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/wsl.wprp" -OutFile $wprpFile
144 -}
145 -
146 -if (Test-Path "$PSScriptRoot/networking.sh")
147 -{
148 - Copy-Item "$PSScriptRoot/networking.sh" $networkingBashScript
149 -}
150 -else
151 -{
152 - Write-Host -ForegroundColor Yellow "networking.sh not found in the current directory. Downloading it from GitHub."
153 - Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/networking.sh" -OutFile $networkingBashScript
154 -}
155 -
156 -# Retrieve WSL version and wslconfig file
157 -get-appxpackage MicrosoftCorporationII.WindowsSubsystemforLinux > $folder/appxpackage.txt
158 -
159 -$wslconfig = "$env:USERPROFILE/.wslconfig"
160 -if (Test-Path $wslconfig)
161 -{
162 - Copy-Item $wslconfig $folder
163 -}
164 -
165 -# Collect Linux & Windows network state before the repro
166 -& wsl.exe -u $superUser -e $networkingBashScript 2>&1 > $folder/linux_network_configuration_before.log
167 -
168 -Collect-WindowsNetworkState "before_repro"
169 -
170 -if ($RestartWslReproMode)
171 -{
172 - # The WSL HNS network is created once per boot. Resetting it to collect network creation logs.
173 - # Note: The below HNS command applies only to WSL in NAT mode
174 - Get-HnsNetwork | Where-Object {$_.Name -eq 'WSL' -Or $_.Name -eq 'WSL (Hyper-V firewall)'} | Remove-HnsNetwork
175 -
176 - # Stop WSL.
177 - net.exe stop WslService
178 - if(-not $?)
179 - {
180 - net.exe stop LxssManager
181 - }
182 -}
183 -
184 -# Start logging.
185 -$wprOutputLog = "$folder/wpr.txt"
186 -
187 -wpr.exe -start "$wprpFile!$wprpProfile" -filemode 2>&1 >> $wprOutputLog
188 -if ($LastExitCode -Ne 0)
189 -{
190 - Write-Host -ForegroundColor Yellow "Log collection failed to start (exit code: $LastExitCode), trying to reset it."
191 - wpr.exe -cancel 2>&1 >> $wprOutputLog
192 -
193 - wpr.exe -start "$wprpFile!$wprpProfile" -filemode 2>&1 >> $wprOutputLog
194 - if ($LastExitCode -Ne 0)
195 - {
196 - Write-Host -ForegroundColor Red "Couldn't start log collection (exitCode: $LastExitCode)"
197 - }
198 -}
199 -
200 -# Start packet capture using pktmon
201 -pktmon start -c --flags 0x1A --file-name "$folder/pktmon.etl" | out-null
202 -
203 -# Start WFP capture
204 -netsh wfp capture start file="$folder/wfpdiag.cab"
205 -
206 -# Start tcpdump. Using a try/catch as tcpdump might not be installed
207 -$tcpdumpProcess = $null
208 -try
209 -{
210 - $tcpdumpProcess = Start-Process wsl.exe -ArgumentList "-u $superUser tcpdump -n -i any -e -vvv > $folder/tcpdump.log" -PassThru
211 -}
212 -catch {}
213 -
214 -try
215 -{
216 - Write-Host -NoNewLine -ForegroundColor Green "Log collection is running. Please reproduce the problem and press any key to save the logs."
217 -
218 - $KeysToIgnore =
219 - 16, # Shift (left or right)
220 - 17, # Ctrl (left or right)
221 - 18, # Alt (left or right)
222 - 20, # Caps lock
223 - 91, # Windows key (left)
224 - 92, # Windows key (right)
225 - 93, # Menu key
226 - 144, # Num lock
227 - 145, # Scroll lock
228 - 166, # Back
229 - 167, # Forward
230 - 168, # Refresh
231 - 169, # Stop
232 - 170, # Search
233 - 171, # Favorites
234 - 172, # Start/Home
235 - 173, # Mute
236 - 174, # Volume Down
237 - 175, # Volume Up
238 - 176, # Next Track
239 - 177, # Previous Track
240 - 178, # Stop Media
241 - 179, # Play
242 - 180, # Mail
243 - 181, # Select Media
244 - 182, # Application 1
245 - 183 # Application 2
246 -
247 - $Key = $null
248 - while ($Key -Eq $null -Or $Key.VirtualKeyCode -Eq $null -Or $KeysToIgnore -Contains $Key.VirtualKeyCode)
249 - {
250 - if ([console]::KeyAvailable)
251 - {
252 - $Key = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown')
253 - }
254 - else
255 - {
256 - Start-Sleep -Seconds 1
257 - }
258 - }
259 -
260 - Write-Host "`nSaving logs..."
261 -}
262 -finally
263 -{
264 - try
265 - {
266 - wsl.exe -u $superUser killall tcpdump
267 - if ($tcpdumpProcess -ne $null)
268 - {
269 - Wait-Process -InputObject $tcpdumpProcess -Timeout 10
270 - }
271 - }
272 - catch {}
273 -
274 - netsh wfp capture stop
275 - pktmon stop | out-null
276 - wpr.exe -stop $folder/logs.etl 2>&1 >> $wprOutputLog
277 -}
278 -
279 -# Collect Linux & Windows network state after the repro
280 -& wsl.exe -u $superUser -e $networkingBashScript 2>&1 > $folder/linux_network_configuration_after.log
281 -
282 -Collect-WindowsNetworkState "after_repro"
283 -
284 -try
285 -{
286 - # Collect HNS events from past 24 hours
287 - $events = Get-WinEvent -ProviderName Microsoft-Windows-Host-Network-Service | Where-Object { $_.TimeCreated -ge ((Get-Date) - (New-TimeSpan -Day 1)) }
288 - ($events | ForEach-Object { '{0},{1},{2},{3}' -f $_.TimeCreated, $_.Id, $_.LevelDisplayName, $_.Message }) -join [environment]::NewLine | Out-File -FilePath "$folder/hns_events.log" -Append
289 -}
290 -catch {}
291 -
292 -# Collect the old Tcpip6 registry values - as they can break WSL if DisabledComponents is set to 0xff
293 -# see https://learn.microsoft.com/en-us/troubleshoot/windows-server/networking/configure-ipv6-in-windows
294 -try
295 -{
296 - Get-Item HKLM:SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters | Out-File -FilePath "$folder/tcpip6_parameters.log" -Append
297 -}
298 -catch {}
299 -
300 -# Collect the setup and NetSetup log files
301 -$netSetupPath = "$env:WINDIR/logs/netsetup"
302 -if (Test-Path $netSetupPath)
303 -{
304 - Copy-Item $netSetupPath/* $folder
305 -}
306 -
307 -$setupApiPath = "$env:WINDIR/inf/setupapi.dev.log"
308 -if (Test-Path $setupApiPath)
309 -{
310 - Copy-Item $setupApiPath $folder
311 -}
312 -
313 -Remove-Item $wprpFile
314 -Remove-Item $networkingBashScript
315 -
316 -$logArchive = "$(Resolve-Path $folder).zip"
317 -Compress-Archive -Path $folder -DestinationPath $logArchive
318 -Remove-Item $folder -Recurse
319 -
320 -Write-Host -ForegroundColor Green "Logs saved in: $logArchive. Please attach that file to the GitHub issue."
diagnostics/collect-wsl-logs.ps1
+143 -1
@@ -3,11 +3,45 @@
3 [CmdletBinding()]
4 Param (
5 $LogProfile = $null,
6 - [switch]$Dump = $false
6 + [switch]$Dump = $false,
7 + [switch]$RestartWslReproMode = $false
8 )
9
10 Set-StrictMode -Version Latest
11
12 +function Collect-WindowsNetworkState {
13 + param (
14 + $Folder,
15 + $ReproStep
16 + )
17 +
18 + # Collect host networking state relevant for WSL
19 + # Using a try/catch for commands below, as some of them do not exist on all OS versions
20 +
21 + try { Get-NetAdapter -includeHidden | select Name,ifIndex,NetLuid,InterfaceGuid,Status,MacAddress,MtuSize,InterfaceType,Hidden,HardwareInterface,ConnectorPresent,MediaType,PhysicalMediaType | Out-File -FilePath "$Folder/Get-NetAdapter_$ReproStep.log" -Append } catch {}
22 + try { & netsh nlm query all $Folder/nlmquery_"$ReproStep".log } catch {}
23 + try { Get-NetIPConfiguration -All -Detailed | Out-File -FilePath "$Folder/Get-NetIPConfiguration_$ReproStep.log" -Append } catch {}
24 + try { Get-NetRoute | Out-File -FilePath "$Folder/Get-NetRoute_$ReproStep.log" -Append } catch {}
25 + try { Get-NetFirewallHyperVVMCreator | Out-File -FilePath "$Folder/Get-NetFirewallHyperVVMCreator_$ReproStep.log" -Append } catch {}
26 + try { Get-NetFirewallHyperVVMSetting -PolicyStore ActiveStore | Out-File -FilePath "$Folder/Get-NetFirewallHyperVVMSetting_ActiveStore_$ReproStep.log" -Append } catch {}
27 + try { Get-NetFirewallHyperVProfile -PolicyStore ActiveStore | Out-File -FilePath "$Folder/Get-NetFirewallHyperVProfile_ActiveStore_$ReproStep.log" -Append } catch {}
28 + try { Get-NetFirewallHyperVRule -PolicyStore ActiveStore | Out-File -FilePath "$Folder/Get-NetFirewallHyperVRule_ActiveStore_$ReproStep.log" -Append } catch {}
29 + try { Get-NetFirewallRule -PolicyStore ActiveStore | Out-File -FilePath "$Folder/Get-NetFirewallRule_ActiveStore_$ReproStep.log" -Append } catch {}
30 + try { Get-NetFirewallProfile -PolicyStore ActiveStore | Out-File -FilePath "$Folder/Get-NetFirewallProfile_ActiveStore_$ReproStep.log" -Append } catch {}
31 + try { Get-NetFirewallHyperVPort | Out-File -FilePath "$Folder/Get-NetFirewallHyperVPort_$ReproStep.log" -Append } catch {}
32 + try { & hnsdiag.exe list all 2>&1 > $Folder/hnsdiag_list_all_"$ReproStep".log } catch {}
33 + try { & hnsdiag.exe list endpoints -df 2>&1 > $Folder/hnsdiag_list_endpoints_"$ReproStep".log } catch {}
34 + try {
35 + foreach ($port in Get-NetFirewallHyperVPort) {
36 + & vfpctrl.exe /port $port.PortName /get-port-state 2>&1 > "$Folder/vfp-port-$($port.PortName)-get-port-state_$ReproStep.log"
37 + & vfpctrl.exe /port $port.PortName /list-rule 2>&1 > "$Folder/vfp-port-$($port.PortName)-list-rule_$ReproStep.log"
38 + }
39 + } catch {}
40 + try { & vfpctrl.exe /list-vmswitch-port 2>&1 > $Folder/vfpctrl_list_vmswitch_port_"$ReproStep".log } catch {}
41 + try { Get-VMSwitch | select Name,Id,SwitchType | Out-File -FilePath "$Folder/Get-VMSwitch_$ReproStep.log" -Append } catch {}
42 + try { Get-NetUdpEndpoint | Out-File -FilePath "$Folder/Get-NetUdpEndpoint_$ReproStep.log" -Append } catch {}
43 +}
44 +
45 $folder = "WslLogs-" + (Get-Date -Format "yyyy-MM-dd_HH-mm-ss")
46 mkdir -p $folder | Out-Null
47
@@ -52,6 +86,40 @@ else
86 }
87 }
88
89 +# Networking-specific setup
90 +if ($LogProfile -eq "networking")
91 +{
92 + # Copy/download networking.sh script
93 + $networkingBashScript = "$folder/networking.sh"
94 + if (Test-Path "$PSScriptRoot/networking.sh")
95 + {
96 + Copy-Item "$PSScriptRoot/networking.sh" $networkingBashScript
97 + }
98 + else
99 + {
100 + Write-Host -ForegroundColor Yellow "networking.sh not found in the current directory. Downloading it from GitHub."
101 + Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/networking.sh" -OutFile $networkingBashScript
102 + }
103 +
104 + # Detect the super user (uid=0, not necessarily named "root" - see #11693)
105 + $superUser = & wsl.exe -- id -nu 0
106 +
107 + # Collect Linux & Windows network state before the repro
108 + & wsl.exe -u $superUser -e $networkingBashScript 2>&1 > $folder/linux_network_configuration_before.log
109 + Collect-WindowsNetworkState -Folder $folder -ReproStep "before_repro"
110 +
111 + if ($RestartWslReproMode)
112 + {
113 + # The WSL HNS network is created once per boot. Resetting it to collect network creation logs.
114 + # Note: The below HNS command applies only to WSL in NAT mode
115 + Get-HnsNetwork | Where-Object {$_.Name -eq 'WSL' -Or $_.Name -eq 'WSL (Hyper-V firewall)'} | Remove-HnsNetwork
116 +
117 + # Stop WSL
118 + net.exe stop WslService
119 + if(-not $?) { net.exe stop LxssManager }
120 + }
121 +}
122 +
123 reg.exe export HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Lxss $folder/HKCU.txt 2>&1 | Out-Null
124 reg.exe export HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Lxss $folder/HKLM.txt 2>&1 | Out-Null
125 reg.exe export HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\P9NP $folder/P9NP.txt 2>&1 | Out-Null
@@ -106,6 +174,24 @@ if ($LastExitCode -Ne 0)
174 }
175 }
176
177 +# Start networking-specific captures
178 +$tcpdumpProcess = $null
179 +if ($LogProfile -eq "networking")
180 +{
181 + pktmon start -c --flags 0x1A --file-name "$folder/pktmon.etl" | out-null
182 + netsh wfp capture start file="$folder/wfpdiag.cab"
183 +
184 + # Ensure WSL is running before collecting network state
185 + & wsl.exe -- true 2>&1 | Out-Null
186 +
187 + # Start tcpdump (may not be installed)
188 + try
189 + {
190 + $tcpdumpProcess = Start-Process wsl.exe -ArgumentList "-u $superUser tcpdump -n -i any -e -vvv > $folder/tcpdump.log" -WindowStyle Hidden -PassThru
191 + }
192 + catch {}
193 +}
194 +
195 try
196 {
197 Write-Host -NoNewLine "Log collection is running. Please "
@@ -151,9 +237,65 @@ try
237 }
238 finally
239 {
240 + # Stop networking-specific captures
241 + if ($LogProfile -eq "networking")
242 + {
243 + try
244 + {
245 + wsl.exe -u $superUser killall tcpdump
246 + if ($tcpdumpProcess -ne $null)
247 + {
248 + Wait-Process -InputObject $tcpdumpProcess -Timeout 10
249 + }
250 + }
251 + catch {}
252 +
253 + netsh wfp capture stop
254 + pktmon stop | out-null
255 + }
256 +
257 wpr.exe -stop $folder/logs.etl 2>&1 >> $wprOutputLog
258 }
259
260 +# Networking-specific post-repro collection
261 +if ($LogProfile -eq "networking")
262 +{
263 + # Collect Linux & Windows network state after the repro
264 + & wsl.exe -u $superUser -e $networkingBashScript 2>&1 > $folder/linux_network_configuration_after.log
265 + Collect-WindowsNetworkState -Folder $folder -ReproStep "after_repro"
266 +
267 + try
268 + {
269 + # Collect HNS events from past 24 hours
270 + $events = Get-WinEvent -ProviderName Microsoft-Windows-Host-Network-Service | Where-Object { $_.TimeCreated -ge ((Get-Date) - (New-TimeSpan -Day 1)) }
271 + ($events | ForEach-Object { '{0},{1},{2},{3}' -f $_.TimeCreated, $_.Id, $_.LevelDisplayName, $_.Message }) -join [environment]::NewLine | Out-File -FilePath "$folder/hns_events.log" -Append
272 + }
273 + catch {}
274 +
275 + # Collect the old Tcpip6 registry values - as they can break WSL if DisabledComponents is set to 0xff
276 + # see https://learn.microsoft.com/en-us/troubleshoot/windows-server/networking/configure-ipv6-in-windows
277 + try
278 + {
279 + Get-Item HKLM:SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters | Out-File -FilePath "$folder/tcpip6_parameters.log" -Append
280 + }
281 + catch {}
282 +
283 + # Collect the setup and NetSetup log files
284 + $netSetupPath = "$env:WINDIR/logs/netsetup"
285 + if (Test-Path $netSetupPath)
286 + {
287 + Copy-Item $netSetupPath/* $folder
288 + }
289 +
290 + $setupApiPath = "$env:WINDIR/inf/setupapi.dev.log"
291 + if (Test-Path $setupApiPath)
292 + {
293 + Copy-Item $setupApiPath $folder
294 + }
295 +
296 + Remove-Item $networkingBashScript
297 +}
298 +
299 if ($Dump)
300 {
301 $Assembly = [PSObject].Assembly.GetType('System.Management.Automation.WindowsErrorReporting')
triage/config.yml
+1 -1
@@ -21,7 +21,7 @@ logs_rules:
21
22 The script will output the path of the log file once done.
23
24 - If this is a networking issue, please use [collect-networking-logs.ps1](https://github.com/Microsoft/WSL/blob/master/diagnostics/collect-networking-logs.ps1), following the instructions in [Collect WSL logs for networking issues](https://github.com/microsoft/WSL/blob/master/CONTRIBUTING.md#collect-wsl-logs-for-networking-issues)
24 + If this is a networking issue, please use `.\collect-wsl-logs.ps1 -LogProfile networking` instead, following the instructions in [Collect WSL logs for networking issues](https://github.com/microsoft/WSL/blob/master/CONTRIBUTING.md#collect-wsl-logs-for-networking-issues)
25
26 Once completed please upload the output files to this GitHub issue.
27