Skip to content

Commit 56e7ee2

Browse files
committed
Add hcs container killing to -hard-reset and -destructive-reset
1 parent f3f78a5 commit 56e7ee2

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

wsl-reset.ps1

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ switch ($true) {
2828
if (-not (Get-AppxPackage *WindowsSubsystemForLinux* | Remove-AppxPackage -ErrorAction SilentlyContinue 2>$null)) {
2929
Disable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux -ErrorAction SilentlyContinue 2>$null
3030
}
31+
$containersJson = & hcsdiag list -raw
32+
$containers = $containersJson | ConvertFrom-Json
33+
$containerGuids = $containers | ForEach-Object { $_.Id }
34+
foreach ($containerGuid in $containerGuids) {
35+
& hcsdiag kill $containerGuid
36+
}
3137
wsl.exe --install --no-launch --no-distribution
3238
Write-Host "WSL has been shutdown and re-installed."
3339
}
@@ -48,6 +54,12 @@ switch ($true) {
4854
if (-not (Get-AppxPackage *WindowsSubsystemForLinux* | Remove-AppxPackage -ErrorAction SilentlyContinue 2>$null)) {
4955
Disable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux -ErrorAction SilentlyContinue 2>$null
5056
}
57+
$containersJson = & hcsdiag list -raw
58+
$containers = $containersJson | ConvertFrom-Json
59+
$containerGuids = $containers | ForEach-Object { $_.Id }
60+
foreach ($containerGuid in $containerGuids) {
61+
& hcsdiag kill $containerGuid
62+
}
5163
wsl.exe --install --no-launch --no-distribution
5264
Write-Host "WSL has been shutdown, all distros unregistered, and WSL has been re-installed."
5365
}

0 commit comments

Comments
 (0)