I have a mobile VPN client that I want to backup to. The problem is that it does not have a static IP to due it being L2TP/IPSec. Thats the bad news. The good news is that there wont be too many VPN clients (at most 10 if that) so Ill be to search for it easy.

Basically, I should go thru a list of IPs from to and check if the IP is up and running (ping). Once I check it is up and running, I should check for a path // and just to be 100% sure its the correct place, Ill serach for a single text file with a single name such as "IAMTHECORRECTVPNBACKUPSERVER.txt" once that is done, I start a robocopy there....

I have the robocopy implemented in PowerShell now I need to implement the pinging and searching the correct IP. How could I do this?

3 Years
Discussion Span
Last Post by Kayasax

First is a reserved adress to designate a subnetwork, a host can't have the last octet equal to 0 .
That said, if you want to scan from to you can do

    if( test-connexion -quiet 192.168.250.$_ -eq $true){ #ping test
        if( test-path \\192.168.250.$_\path\IAMTHECORRECTVPNBACKUPSERVER.txt -eq $true ){
            #do robocopy
            write-host "host 192.168.250.$_ is not the backupserver"
        write-host "host 192.168.250.$_  is offline"
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.