21 lines
774 B
PowerShell
21 lines
774 B
PowerShell
## Set the path to the OpenVPN uninstaller
|
|
$INSTALL_PATH = "${Env:ProgramFiles}\OpenVPN"
|
|
|
|
If ( Test-Path "${INSTALL_PATH}\Uninstall.exe" )
|
|
{
|
|
## Disconnect all connected VPN configurations
|
|
Start-Process "${INSTALL_PATH}\bin\openvpn-gui.exe" -ArgumentList '--command disconnect_all' -Wait
|
|
|
|
## End OpenVPN if it's running
|
|
Get-Process | Where { $_.Name -like "openvpn*" } | Stop-Process -Force
|
|
|
|
## Uninstall OpenVPN
|
|
Write-Output "Uninstalling OpenVPN"
|
|
Start-Process "${INSTALL_PATH}\Uninstall.exe" -ArgumentList '/S' -Wait
|
|
|
|
## Delete lingering directories
|
|
Write-Output "Deleting ${Env:ProgramFiles}\OpenVPN"
|
|
Remove-Item "${Env:ProgramFiles}\OpenVPN" -Recurse -Force
|
|
}
|
|
|
|
Else { Write-Output "OpenVPN is not installed on this endpoint." } |