To Check the status of VPN Connection


This topic contains 5 replies, has 3 voices, and was last updated by Profile photo of Aboobacker Ansari Aboobacker Ansari 10 months, 1 week ago.

  • Author
  • #33070
    Profile photo of Aboobacker Ansari
    Aboobacker Ansari

    Hi ,

    I am new to powershell, have completed the 6 hours course recently, i am currently developing small tool, i want to check our vpn status whether connected or not,
    i have used

    gwmi win32_networkadapterconfiguration -Filter 'Description="MyVPN Adapter"' | ft IPEnabled

    Shows as false even if the vpn is connected, how to detect the status, please help me out.

    Thanks in advance

  • #33095
    Profile photo of tommymaynard

    If it's showing False and you're truly connected using your VPN adapter, then my assumption is that 'MyVPN Adapter,' or whatever it's called, is not the adapter you actually want. I use the Cisco AnyConnect VPN, and its IPEnabled property is listed as True. Have you run a more general command, to see more results, such as: Get-WmiObject -Class Win32_NetworkAdapterConfiguration | Select-Object Description,IPEnabled. What does this list when your VPN adapter is connected and not connected?

  • #33102
    Profile photo of Aboobacker Ansari
    Aboobacker Ansari

    Hi tommy,

    First of all thanks for your kind support,

    We use Aventail VPN and I get false for the both while connected and disconnected, and FYI I am checking this in my company, not my personal.

    PS C:\windows\system32>
    gwmi win32_networkadapterconfiguration -Filter 'Description="Aventail VPN Adapter"' | Select-Object Description,IPEnabled

    Description IPEnabled
    ———– ———
    Aventail VPN Adapter False


  • #33117
    Profile photo of tommymaynard

    Since the status of your VPN adapter isn't properly represented in the Win32_NetworkAdapterConfiguration class, I would view this as a vendor support issue. You should contact the people that make Aventail VPN for assistance with how to determine if there's an active VPN connection, or not. You might also try and determine if their product ships with a command line tool that would report this type of information. If so, you may be able to leverage this in PowerShell.

  • #33118
    Profile photo of Dan Potter
    Dan Potter

    some really simple alternate tests.

    test-connection to one of your servers on the vpn network

  • #33173
    Profile photo of Aboobacker Ansari
    Aboobacker Ansari

    Thanks Tommy,

    Thanks Dan Potter,
    'test-connection' Alternate way worked out for me, I have got server name, so when VPN connected I get reply, when not connected it throws error, so this way is ok for me to see if VPN is connected or NOT.
    Once again thanks Dan Potter!!!

    and thanks to Tommy for your time to reply

You must be logged in to reply to this topic.