<# .SYNOPSIS Removes the OtOpcUaFocasHost Windows service. .DESCRIPTION Companion to Install-FocasHost.ps1. Stops + unregisters the service via NSSM. Idempotent — succeeds silently if the service doesn't exist. .EXAMPLE .\Uninstall-FocasHost.ps1 #> [CmdletBinding()] param( [string]$ServiceName = 'OtOpcUaFocasHost', [string]$NssmPath = 'C:\Program Files\nssm\nssm.exe' ) $ErrorActionPreference = 'Stop' $svc = Get-Service -Name $ServiceName -ErrorAction SilentlyContinue if (-not $svc) { Write-Host "Service '$ServiceName' not present — nothing to do."; return } if (-not (Test-Path $NssmPath)) { throw "nssm.exe not found at '$NssmPath'." } & $NssmPath stop $ServiceName confirm | Out-Null & $NssmPath remove $ServiceName confirm | Out-Null Write-Host "Removed '$ServiceName'."