You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过PowerShell关闭现有SSL隧道及残留VPN连接?

解决SWGVC VPN隧道残留问题

问题原因

Get-VpnConnection 无法识别SWGVC的隧道,是因为它属于第三方SSL VPN客户端,并非系统原生的VPN连接组件,其创建的隧道、虚拟网卡和路由条目不会被系统内置VPN cmdlet接管。

具体解决步骤

  1. 彻底终止SWGVC相关进程
    主进程结束后可能残留子进程,需一次性清理所有关联进程:
# 终止RDP进程
Stop-Process -Name mstsc -Force -ErrorAction SilentlyContinue
# 终止所有SWGVC相关进程(含子进程)
Get-Process | Where-Object {$_.ProcessName -like "*SWGVC*"} | Stop-Process -Force -ErrorAction SilentlyContinue
  1. 清理SWGVC虚拟网卡
    SWGVC会创建专属虚拟网卡承载隧道,进程结束后可能未自动销毁,需手动禁用:
# 查找SWGVC/SSL VPN相关虚拟网卡
$vpnAdapter = Get-NetAdapter | Where-Object {$_.Name -match "SWGVC|SSL VPN"}
# 禁用找到的虚拟网卡
if ($vpnAdapter) {
    $vpnAdapter | Disable-NetAdapter -Confirm:$false
}
  1. 删除VPN残留路由条目
    VPN会添加定向路由让办公网络流量走隧道,进程终止后路由可能仍存在,需清理:
# 删除所有关联SWGVC虚拟网卡的路由条目
Get-NetRoute | Where-Object {$_.InterfaceAlias -match "SWGVC|SSL VPN"} | Remove-NetRoute -Confirm:$false -ErrorAction SilentlyContinue

一键执行脚本

将上述步骤整合为单段命令,一次性完成清理:

# 终止目标进程
Stop-Process -Name mstsc -Force -ErrorAction SilentlyContinue
Get-Process | Where-Object {$_.ProcessName -like "*SWGVC*"} | Stop-Process -Force -ErrorAction SilentlyContinue

# 处理虚拟网卡
$vpnAdapter = Get-NetAdapter | Where-Object {$_.Name -match "SWGVC|SSL VPN"}
if ($vpnAdapter) {
    $vpnAdapter | Disable-NetAdapter -Confirm:$false
}

# 清理残留路由
Get-NetRoute | Where-Object {$_.InterfaceAlias -match "SWGVC|SSL VPN"} | Remove-NetRoute -Confirm:$false -ErrorAction SilentlyContinue

极端情况处理

若执行后仍能ping通办公网络,可重启网络服务(会断开当前所有网络连接):

Restart-Service -Name "Netman" -Force

内容的提问来源于stack exchange,提问作者Eray Balkanli

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.18 10:40:33