Skip to content

Instantly share code, notes, and snippets.

@chuyeow
Created May 27, 2020 01:10
Show Gist options
  • Save chuyeow/e771b6bdba89a7f45222174cc9a9ec53 to your computer and use it in GitHub Desktop.
Save chuyeow/e771b6bdba89a7f45222174cc9a9ec53 to your computer and use it in GitHub Desktop.
Convenient way to connect to an IKEv2 VPN on macOS
set vpnServiceName to "Your VPN name in Network Preferences"
tell application "System Events"
tell process "SystemUIServer"
set vpnMenu to (menu bar item 1 of menu bar 1 where description is "VPN")
tell vpnMenu to click
set connectionStatusItem to (menu item 1 of menu 1 of vpnMenu)
if title of connectionStatusItem is equal to ("Connect " & vpnServiceName) then
tell connectionStatusItem to click
end if
end tell
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment