Skip to content

Commit 893486a

Browse files
Merge pull request #11249 from SlavyMihov/patch-1
Minor updates to collect-networking-logs.ps1
2 parents 6c800da + 5c5e6dc commit 893486a

1 file changed

Lines changed: 30 additions & 6 deletions

File tree

diagnostics/collect-networking-logs.ps1

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,26 @@ mkdir -p $folder
1111
$logProfile = "$folder/wsl_networking.wprp"
1212
$networkingBashScript = "$folder/networking.sh"
1313

14-
# Download supporting files
15-
Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/wsl_networking.wprp" -OutFile $logProfile
16-
Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/networking.sh" -OutFile $networkingBashScript
14+
# Copy/Download supporting files
15+
if (Test-Path "$PSScriptRoot/wsl_networking.wprp")
16+
{
17+
Copy-Item "$PSScriptRoot/wsl_networking.wprp" $logProfile
18+
}
19+
else
20+
{
21+
Write-Host -ForegroundColor Yellow "wsl_networking.wprp not found in the current directory. Downloading it from GitHub."
22+
Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/wsl_networking.wprp" -OutFile $logProfile
23+
}
24+
25+
if (Test-Path "$PSScriptRoot/networking.sh")
26+
{
27+
Copy-Item "$PSScriptRoot/networking.sh" $networkingBashScript
28+
}
29+
else
30+
{
31+
Write-Host -ForegroundColor Yellow "networking.sh not found in the current directory. Downloading it from GitHub."
32+
Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/networking.sh" -OutFile $networkingBashScript
33+
}
1734

1835
# Retrieve WSL version and wslconfig file
1936
get-appxpackage MicrosoftCorporationII.WindowsSubsystemforLinux > $folder/appxpackage.txt
@@ -105,9 +122,16 @@ try
105122
183 # Application 2
106123

107124
$Key = $null
108-
while ($Key -Eq $null -Or $Key.VirtualKeyCode -Eq $null -Or $KeysToIgnore -Contains $Key.VirtualKeyCode)
125+
while (($Key -Eq $null -Or $Key.VirtualKeyCode -Eq $null -Or $KeysToIgnore -Contains $Key.VirtualKeyCode) -and ($null -eq $tcpdumpProcess -or $tcpdumpProcess.HasExited -eq $false))
109126
{
110-
$Key = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown')
127+
if ([console]::KeyAvailable)
128+
{
129+
$Key = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown')
130+
}
131+
else
132+
{
133+
Start-Sleep -Seconds 1
134+
}
111135
}
112136

113137
Write-Host "`nSaving logs..."
@@ -238,4 +262,4 @@ $logArchive = "$(Resolve-Path $folder).zip"
238262
Compress-Archive -Path $folder -DestinationPath $logArchive
239263
Remove-Item $folder -Recurse
240264

241-
Write-Host -ForegroundColor Green "Logs saved in: $logArchive. Please attach that file to the GitHub issue."
265+
Write-Host -ForegroundColor Green "Logs saved in: $logArchive. Please attach that file to the GitHub issue."

0 commit comments

Comments
 (0)