2

I am working on a script to suggest the best vpn server for the client

I want to know if the vpn server is now Available through powershell

Example:

ping my.vpnserver.com
if errorlevel 1 echo The VPN Server Not Available

I tried with ping command but in all cases it shows me that vpn server is connected

I want a solution for this

0

2 Answers 2

1

You need to check for the open port and not necessarily ping. You could block ping and still allow VPN on another port for the VPN server and connections to use.

For example Test-NetConnection -ComputerName "my.vpnserver.com" -Port 5555 replacing the port number with the one the VPN server is listening on—and your router from the Internet into your network allows to go to—assuming it's Internet connected and that's how you're testing it.

Note: If you have DNS issues, test using the IP address of the VPN server rather than the DNS name to potentially narrow down where troubleshooting should more precisely start.

Supporting Resource

  • Test-NetConnection

    • -Port

      Specifies the TCP port number on the remote computer. The cmdlet uses this port number to test connectivity to the remote computer.

0

In PowerShell you can use the Test-Connection command.

Here is an example of using it :

if (Test-Connection -computername $computer -Quiet -Count 1) {
    # succeeded
} else {
    # failed
}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .