Powershell script to find valid L2TP/IPSec VPN client and do robocopy transfer

Im using a L2TP/IPSec VPN mobile client and a ZyXEL ZyWALL USG50 as the server. I cannot find a way to set a static IP for a VPN mobile client so I cannot be guaranteed that it will be the same IP. In order to successfully transfer make the RoboCopy, I need to search for the VPN mobile client's IP I want to make the transfer to.

Obviously, a lot of time is wasted just searching for it but I really have no other choice.

On a "positive" note, Im sure there isnt going to be much VPN mobile clients so Im pretty sure it is always going to be but at MOST it would be

My idea for the script is:
1.Check if a IP is running (ping)
2.Check if a path on that IP actually exists. For example //
3.Just to be sure this is the real location I want to transfer everything, check for a file such as "IAMTHECORRECTVPNBACKUPSERVER.txt"

4.Once those conditions are met (lets say for example purposes it is the IP of

$IP=" c:\windows\system32\Robocopy.exe "D:\folder" "\\folder" /E /MT:20 /R:50 /W:10 /V /ETA /LOG:c:\robocopy$(Get-Date -format 'ddMMyyyyHHmmss')$IP.txt

5.Exit and finish the scheduled task

How could I do this in PowerShell?
Sign In or Register to comment.