Article 4S5PK Translating Linux shell script to Windows10 MSDOS or Powershell

Translating Linux shell script to Windows10 MSDOS or Powershell

by
P5music
from LinuxQuestions.org on (#4S5PK)
Hello,
I managed to create a Linux shell script that is able to switch between two different wifi services that very often hang but which can be manually reconnected with success.

Code:while (true) do

if ! [ "`ping -c 1 -W 1 www.google.it`" ]; then
if (nmcli connection show --active | grep -c "FirstWiFi"); then
nmcli connection up id "SecondWiFi"
echo "switched to SecondWiFi"
else
nmcli connection up id "FirstWiFi"
echo "switched to FirstWiFi"
fi
fi

doneI am not suggesting to use this script because I do not know if it safe.

Now I need the same functionality on a Windows10 system.
I know that MSDOS shell is more limited than the bash shell or the like. But Windows10 has also Powershell.
As you can see the script is very simple so I think it can be translated. I do not know how to do it.
Maybe some easy suggestions can be found here.
Thank you in advancelatest?d=yIl2AUoC8zA latest?i=MNOUvn6ExTQ:8kr_lknXGXI:F7zBnMy latest?i=MNOUvn6ExTQ:8kr_lknXGXI:V_sGLiP latest?d=qj6IDK7rITs latest?i=MNOUvn6ExTQ:8kr_lknXGXI:gIN9vFwMNOUvn6ExTQ
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments