Skip to content

Commit

Permalink
Merge pull request #11249 from SlavyMihov/patch-1
Browse files Browse the repository at this point in the history
Minor updates to collect-networking-logs.ps1
  • Loading branch information
CatalinFetoiu committed Mar 7, 2024
2 parents 6c800da + 5c5e6dc commit 893486a
Showing 1 changed file with 30 additions and 6 deletions.
36 changes: 30 additions & 6 deletions diagnostics/collect-networking-logs.ps1
Expand Up @@ -11,9 +11,26 @@ mkdir -p $folder
$logProfile = "$folder/wsl_networking.wprp"
$networkingBashScript = "$folder/networking.sh"

# Download supporting files
Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/wsl_networking.wprp" -OutFile $logProfile
Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/networking.sh" -OutFile $networkingBashScript
# Copy/Download supporting files
if (Test-Path "$PSScriptRoot/wsl_networking.wprp")
{
Copy-Item "$PSScriptRoot/wsl_networking.wprp" $logProfile
}
else
{
Write-Host -ForegroundColor Yellow "wsl_networking.wprp not found in the current directory. Downloading it from GitHub."
Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/wsl_networking.wprp" -OutFile $logProfile
}

if (Test-Path "$PSScriptRoot/networking.sh")
{
Copy-Item "$PSScriptRoot/networking.sh" $networkingBashScript
}
else
{
Write-Host -ForegroundColor Yellow "networking.sh not found in the current directory. Downloading it from GitHub."
Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/networking.sh" -OutFile $networkingBashScript
}

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

$Key = $null
while ($Key -Eq $null -Or $Key.VirtualKeyCode -Eq $null -Or $KeysToIgnore -Contains $Key.VirtualKeyCode)
while (($Key -Eq $null -Or $Key.VirtualKeyCode -Eq $null -Or $KeysToIgnore -Contains $Key.VirtualKeyCode) -and ($null -eq $tcpdumpProcess -or $tcpdumpProcess.HasExited -eq $false))
{
$Key = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown')
if ([console]::KeyAvailable)
{
$Key = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown')
}
else
{
Start-Sleep -Seconds 1
}
}

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

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

0 comments on commit 893486a

Please sign in to comment.