Skip to content

Add warning to collect-wsl-logs.ps1 to be displayed when tool is missing#14447

Open
andremueiot wants to merge 3 commits intomicrosoft:masterfrom
andremueiot:user/andremueiot/warn_tool_missing
Open

Add warning to collect-wsl-logs.ps1 to be displayed when tool is missing#14447
andremueiot wants to merge 3 commits intomicrosoft:masterfrom
andremueiot:user/andremueiot/warn_tool_missing

Conversation

@andremueiot
Copy link

Summary of the Pull Request

On executing the log collection script, it will first confirm the required tools tcpdump and iptables are installed. For each tool
missing a warning is displayed, reminding the user that the tool should be installed prior to executing the script to get a more
complete log collection.

PR Checklist

  • Closes: collect-wsl-logs.ps1 should warn users when a required tool is not installed #14427
  • Communication: I've discussed this with core contributors already. If work hasn't been agreed, this work might be rejected
  • Tests: No automated test is deemed necessary to cover the scenarios
  • Localization: Wrote warning in plain English, like the messages already present in the log collection script
  • Dev docs: No doc update needed
  • Documentation updated: No doc update needed

Validation Steps Performed

Ran the command below (from log collection instructions) manually in both scenarios where tools are installed and not installed.
Visually confirmed that both warning messages show up when the respective tool is not installed.
.\collect-wsl-logs.ps1 -LogProfile networking

Andre Muezerie added 3 commits March 13, 2026 16:54
On executing the log collection script, it will first confirm the
required tools tcpdump and iptables are installed. For each tool
missing a warning is displayed, reminding the user that the tool
should be installed prior to executing the script to get a more
complete log collection.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds pre-flight warnings to the Windows-side diagnostics/collect-wsl-logs.ps1 script to inform users (when running the networking log profile) that certain Linux tools should be installed in WSL for more complete log capture.

Changes:

  • Introduces Test-WslApplication to probe for required tools inside WSL and emit Write-Warning when missing.
  • Calls the new check for tcpdump and iptables when -LogProfile networking is selected.

You can also share your feedback on Copilot code review. Take the survey.

# Log warning when tool is not present in WSL
try
{
& wsl.exe -e sh -lc "command -v $Command >/dev/null 2>&1"
Comment on lines +21 to +31
& wsl.exe -e sh -lc "command -v $Command >/dev/null 2>&1"
$available = ($LASTEXITCODE -eq 0)

if (-not $available)
{
Write-Warning "$Name not found in WSL. For a more complete log collection install $Name."
}

return $available
}
catch {}
Comment on lines +116 to +117
Test-WslApplication -Name "tcpdump" -Command "tcpdump --version" | Out-Null
Test-WslApplication -Name "iptables" -Command "iptables --version" | Out-Null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants