mirror of
https://github.com/microsoft/WSL.git
synced 2025-12-11 04:35:57 -06:00
Merge pull request #11014 from microsoft/user/cfetoiu/add_hns_events
collect-networking-logs.ps1: Collect HNS events and update RestartWslReproMode option
This commit is contained in:
commit
212838e05f
@ -30,7 +30,8 @@ if (Test-Path $wslconfig)
|
|||||||
if ($RestartWslReproMode)
|
if ($RestartWslReproMode)
|
||||||
{
|
{
|
||||||
# The WSL HNS network is created once per boot. Resetting it to collect network creation logs.
|
# 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.
|
# Stop WSL.
|
||||||
net.exe stop WslService
|
net.exe stop WslService
|
||||||
@ -222,6 +223,14 @@ try
|
|||||||
}
|
}
|
||||||
catch {}
|
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 $logProfile
|
||||||
Remove-Item $networkingBashScript
|
Remove-Item $networkingBashScript
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user