Skip to content

Commit

Permalink
Merge pull request #11014 from microsoft/user/cfetoiu/add_hns_events
Browse files Browse the repository at this point in the history
collect-networking-logs.ps1: Collect HNS events and update RestartWslReproMode option
  • Loading branch information
CatalinFetoiu committed Jan 13, 2024
2 parents 96bd92e + 8c6dd56 commit 212838e
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion diagnostics/collect-networking-logs.ps1
Expand Up @@ -30,7 +30,8 @@ if (Test-Path $wslconfig)
if ($RestartWslReproMode)
{
# The WSL HNS network is created once per boot. Resetting it to collect network creation logs.
Get-HnsNetwork | Where-Object {$_.Name -eq 'WSL'} | Remove-HnsNetwork
# Note: The below HNS command applies only to WSL in NAT mode
Get-HnsNetwork | Where-Object {$_.Name -eq 'WSL' -Or $_.Name -eq 'WSL (Hyper-V firewall)'} | Remove-HnsNetwork

# Stop WSL.
net.exe stop WslService
Expand Down Expand Up @@ -222,6 +223,14 @@ try
}
catch {}

try
{
# Collect HNS events from past 24 hours
$events = Get-WinEvent -ProviderName Microsoft-Windows-Host-Network-Service | Where-Object { $_.TimeCreated -ge ((Get-Date) - (New-TimeSpan -Day 1)) }
($events | ForEach-Object { '{0},{1},{2},{3}' -f $_.TimeCreated, $_.Id, $_.LevelDisplayName, $_.Message }) -join [environment]::NewLine | Out-File -FilePath "$folder/hns_events.log" -Append
}
catch {}

Remove-Item $logProfile
Remove-Item $networkingBashScript

Expand Down

0 comments on commit 212838e

Please sign in to comment.