Skip to content

Commit

Permalink
Add hcs container killing to -hard-reset and -destructive-reset
Browse files Browse the repository at this point in the history
  • Loading branch information
sirredbeard committed Nov 12, 2023
1 parent f3f78a5 commit 56e7ee2
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions wsl-reset.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ switch ($true) {
if (-not (Get-AppxPackage *WindowsSubsystemForLinux* | Remove-AppxPackage -ErrorAction SilentlyContinue 2>$null)) {
Disable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux -ErrorAction SilentlyContinue 2>$null
}
$containersJson = & hcsdiag list -raw
$containers = $containersJson | ConvertFrom-Json
$containerGuids = $containers | ForEach-Object { $_.Id }
foreach ($containerGuid in $containerGuids) {
& hcsdiag kill $containerGuid
}
wsl.exe --install --no-launch --no-distribution
Write-Host "WSL has been shutdown and re-installed."
}
Expand All @@ -48,6 +54,12 @@ switch ($true) {
if (-not (Get-AppxPackage *WindowsSubsystemForLinux* | Remove-AppxPackage -ErrorAction SilentlyContinue 2>$null)) {
Disable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux -ErrorAction SilentlyContinue 2>$null
}
$containersJson = & hcsdiag list -raw
$containers = $containersJson | ConvertFrom-Json
$containerGuids = $containers | ForEach-Object { $_.Id }
foreach ($containerGuid in $containerGuids) {
& hcsdiag kill $containerGuid
}
wsl.exe --install --no-launch --no-distribution
Write-Host "WSL has been shutdown, all distros unregistered, and WSL has been re-installed."
}
Expand Down

0 comments on commit 56e7ee2

Please sign in to comment.