fixes from testing
Catalin-Emil Fetoiu committed
Oct 19, 2023 at 12:25 UTC
e1fe99e0b489f8d2e4f60a9278939906e74772dc
1 file changed
+13
-11
diagnostics/collect-networking-logs.ps1
+13
-11
@@ -2,14 +2,12 @@
2
3
[CmdletBinding()]
4
Param (
5
- [switch]$DeleteHnsState = $false
5
+ [switch]$DeleteHnsNetwork = $false
6
)
7
8
$folder = "WslNetworkingLogs-" + (Get-Date -Format "yyyy-MM-dd_HH-mm-ss")
9
mkdir -p $folder
10
11
-# TODO! tcpdump??
12
-
11
# Retrieve WSL version and wslconfig file
12
get-appxpackage MicrosoftCorporationII.WindowsSubsystemforLinux > $folder/appxpackage.txt
13
@@ -19,18 +17,22 @@ if (Test-Path $wslconfig)
17
Copy-Item $wslconfig $folder
18
}
19
22
-if ($DeleteHnsState)
20
+# Collect Linux network state before the repro
21
+& wsl.exe -e ./networking.sh 2>&1 > $folder/linux_network_configuration_before.log
22
+
23
+if ($DeleteHnsNetwork)
24
{
25
# The WSL HNS network is created once per boot. Resetting it to collect network creation logs.
26
Get-HnsNetwork | Where-Object {$_.Name -eq 'WSL'} | Remove-HnsNetwork
27
28
# Stop WSL.
28
- net.exe stop WslService || net.exe stop LxssManager
29
+ net.exe stop WslService
30
+ if(-not $?)
31
+ {
32
+ net.exe stop LxssManager
33
+ }
34
}
35
31
-# Collect Linux network state before the repro
32
-& wsl.exe -e ./networking.sh 2>&1 > $folder/linux_network_configuration_before.log
33
-
36
# Start logging.
37
$logProfile = ".\wsl_networking.wprp"
38
$wprOutputLog = "$folder/wpr.txt"
@@ -49,7 +51,7 @@ if ($LastExitCode -Ne 0)
51
}
52
53
# Start packet capture using pktmon
52
-pktmon start -c --flags 0x1A --file-name "$folder/pktmon.etl"
54
+pktmon start -c --flags 0x1A --file-name "$folder/pktmon.etl" | out-null
55
56
# Start WFP capture
57
netsh wfp capture start file="$folder/wfpdiag.cab"
@@ -98,7 +100,7 @@ try
100
finally
101
{
102
netsh wfp capture stop
101
- pktmon stop
103
+ pktmon stop | out-null
104
wpr.exe -stop $folder/logs.etl 2>&1 >> $wprOutputLog
105
}
106
@@ -184,7 +186,7 @@ try
186
}
187
catch {}
188
187
-logArchive = "$(Resolve-Path $folder).zip"
189
+$logArchive = "$(Resolve-Path $folder).zip"
190
Compress-Archive -Path $folder -DestinationPath $logArchive
191
Remove-Item $folder -Recurse
192