Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
Get-NetAdapter | Where-Object {$_.InterfaceDescription -Match "Cisco AnyConnect"} | Set-NetIPInterface -InterfaceMetric 6000


Create a Task to Apply Workaround on VPN Connect

We can create an automatic Windows task which will automatically open the Powershell and run the command for us.

Create the script file anywhere, I created it in my Users\Public\Scripts\ folder and called it UpdateAnyConnectInterfaceMetrics.ps1. You can however create it where you want and name it what you want. Here is the content:

Get-NetAdapter | Where-Object {$_.InterfaceDescription -Match "Cisco AnyConnect"} | Set-NetIPInterface -InterfaceMetric 6000




Now follow these instructions. Do not use quotes when entering file path.

  • Open Task Scheduler
  • Select Action → Click Create Task

  • Name it Update Anyconnect Adapter Interface Metric for WSL2
  • Check Run with highest privileges
  • Select the Triggers Tab

  • Click the New Button


  • Select On Event from the Begin the Task pull down.
  • Select Cisco AnyConnect Secure Mobility Client from the Log.
  • Select acvpnagent from the Source.
  • Enter 2039 for the Event ID.
  • Click OK
  • Select the Action Tab

  • Click New

  • Select Start a program from the Action pulldown.
  • Enter Powershell.exe for the Program/script.
  • Enter C:\Users\Public\Scripts\UpdateAnyConnectInterfaceMetrics.ps1 for the argument.
  • Click OK
  • Click the Conditions Tab

  • Uncheck the option "Start the task only if the computer is on AC power".
  • Click OK to Create the Task.

References

...