$Service = Get-Service -Name iperf3server -ErrorAction SilentlyContinue if ($null -eq $Service) { Write-Host "Service is not installed" } else { & "C:\Program Files\nssm\win64\nssm.exe" stop iperf3server & "C:\Program Files\nssm\win64\nssm.exe" remove iperf3server }