I have a device which is running on a Windows 10 Enterprise , currently i'm looking for a script which can act as a Connection Manager which is like below.
Attached codes below where I tried using metric value but it doesn't work properly.
$formatstring = "{0} : {1}`n{2}`n" +
" + CategoryInfo : {3}`n" +
" + FullyQualifiedErrorId : {4}`n"
$fields = $_.Exception.Message
$gw = "172.21.150.21"
if (Test-Connection -ComputerName $gw -BufferSize 16 -Count 1 -ErrorAction 0 -Quiet)
{
try
{
route change -p 0.0.0.0 MASK 0.0.0.0 192.168.230.21 METRIC 300 IF 13/P
}
catch
{
Write-Host -Foreground Red -Background Black ($formatstring -f $fields)
}
}
else
{
try
{
route change -p 0.0.0.0 MASK 0.0.0.0 192.168.230.21 METRIC 1 IF 13/P
}
catch
{
Write-Host -Foreground Red -Background Black ($formatstring -f $fields)
}
}
Always connected to Cellular Data ( 3G/4G ) and ping check to the primary IP for every 30 seconds and if the ping fails continuously for 1 mins it should go to secondary which is WiFi and keep the connection till the cellular Data connection is back which means if the 30 second ping success in couple of minutes or hours.
WIFI is using SSID and Cellular Data is using APN, I need some example codes for python or else using powershell.