$ErrorActionPreference = 'Continue' if (Test-Path variable:PSNativeCommandUseErrorActionPreference) { $PSNativeCommandUseErrorActionPreference = $false } $nodes = @('hla-swarm-manager', 'hla-swarm-worker1', 'hla-swarm-worker2', 'hla-swarm-registry') foreach ($node in $nodes) { $existing = (& docker ps --all --filter "name=^/${node}$" --format '{{.Names}}') if ($existing -eq $node) { docker rm --force $node | Out-Null if ($LASTEXITCODE -ne 0) { throw "Cannot remove $node" } } } $existingNetwork = (& docker network ls --filter 'name=^hla-swarm-underlay$' --format '{{.Name}}') if ($existingNetwork -eq 'hla-swarm-underlay') { docker network rm hla-swarm-underlay | Out-Null if ($LASTEXITCODE -ne 0) { throw 'Cannot remove hla-swarm-underlay' } } Write-Output 'Removed the disposable three-node Swarm lab and its nested volumes.'