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.
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?
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.
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!!!