How to use PowerShell and/or Python to restart router?
The SSH way
If your router supports SSH access (you probably need to enable it in the router settings), you can try issuing a command via SSH to restart it.
It could be something like ssh USERNAME@ROUTER_ADDRESS reboot
or ssh USERNAME@ROUTER_ADDRESS "sudo reboot"
.
- First, you need to enable SSH access. Ensure that it works by typing smth like
ssh USERNAME@ROUTER_ADDRESS
(if it does, you will be asked for password and, after entering correct password, get into the router's command prompt). - Then determine which command you need to type into the router's command prompt to restart it. It could be just
reboot
. But you may also need to specify exact path like/sbin/reboot
,/usr/sbin/reboot
or etc. And/or you may also need to elevate the privileges likesudo COMMAND
orsu -c 'COMMAND' root
. - I the previous two steps are passed, you can combine logging in into SSH (
ssh USERNAME@ROUTER_ADDRESS
) and issuing a reboot command (e.g.sudo reboot
) into a single command (likessh USERNAME@ROUTER_ADDRESS "sudo reboot"
). You will still be asked for password every time, but it can be avoided (please ping me in comments if you reached this step and want to avoid typing passwords).
The HTTP way
Open Network Monitor in your browser (e.g. in Firefox that's Shift+Ctrl+E) and try to determine which exactly web request is issued when you confirm restart (e.g. in Firefox you can see the whole data of the request).