31 lines
1.3 KiB
PowerShell
31 lines
1.3 KiB
PowerShell
[CmdletBinding()]
|
|
param(
|
|
[string]$Destination = 'C:\NODEDC\dc-amd-connector'
|
|
)
|
|
|
|
Set-StrictMode -Version Latest
|
|
$ErrorActionPreference = 'Stop'
|
|
|
|
function Require-Administrator {
|
|
$identity = [Security.Principal.WindowsIdentity]::GetCurrent()
|
|
$principal = New-Object Security.Principal.WindowsPrincipal($identity)
|
|
if (-not $principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
|
|
throw 'Run this uninstaller from an elevated PowerShell window.'
|
|
}
|
|
}
|
|
|
|
Require-Administrator
|
|
$docker = Get-Command docker -CommandType Application -ErrorAction SilentlyContinue | Select-Object -First 1
|
|
if ($docker -and (Test-Path -LiteralPath (Join-Path $Destination 'docker-compose.yml'))) {
|
|
Push-Location $Destination
|
|
try { & $docker.Path compose down --remove-orphans } finally { Pop-Location }
|
|
}
|
|
|
|
Remove-NetFirewallRule -DisplayName 'NODE.DC DC AMD Connector (NAS only)' -ErrorAction SilentlyContinue
|
|
$startup = [Environment]::GetFolderPath([Environment+SpecialFolder]::Startup)
|
|
$launcher = Join-Path $startup 'NODE.DC DC AMD Connector - Docker Desktop.cmd'
|
|
Remove-Item -LiteralPath $launcher -Force -ErrorAction SilentlyContinue
|
|
Remove-Item -LiteralPath $Destination -Recurse -Force -ErrorAction SilentlyContinue
|
|
|
|
Write-Host 'DC AMD Connector removed. Docker Desktop and unrelated containers were not changed.'
|