diff --git a/test-openvpn.ps1 b/test-openvpn.ps1 index e1fe3ab..6c22c01 100644 --- a/test-openvpn.ps1 +++ b/test-openvpn.ps1 @@ -95,8 +95,12 @@ Function Stop-Gui { } Function Stop-Openvpnservice { - Stop-Service OpenVPNService - Stop-Service OpenVPNServiceLegacy + foreach ($service in 'OpenVPNService', 'OpenVPNServiceLegacy') { + if (Get-Service -Erroraction Ignore $service) { + Stop-Service $service + (Get-Service $service).WaitForStatus('Stopped') + } + } } # Stop all openvpn-related processes