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".

  1. 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).
  2. 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 like sudo COMMAND or su -c 'COMMAND' root.
  3. 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 (like ssh 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).