E
E
Emperor Zizzle2022-02-06 22:54:42
PowerShell
Emperor Zizzle, 2022-02-06 22:54:42

How to automate router reboot via SSH via Powershell?

Hello)
I want to create a script that will allow me to reboot the router by double clicking on the shortcut, instead of going into the web interface and doing everything manually.
Through Powershell, I understand how to do it with my hands:

ssh [email protected]
"enter password"
"press Enter"
reboot


But I don't understand at all how to automate this process through PowerShell, since I have never worked with it. I thought it was simple, in the spirit of creating batch files (one of these, for example, I reboot the machine via RDP, because the Windows developers removed the "reboot" item when connecting remotely), but this, as it turned out, does not work that way.

I found a few examples, found out that there seems to be a SendKeys command, and even tried to apply it, but it didn’t work:(

Please help)

Answer the question

In order to leave comments, you need to log in

3 answer(s)
E
Eugene, 2022-02-07
@BeatHazard

Try to install the Posh-SSH module and use the cmdlets from its composition according to the instructions from here https://habr.com/en/post/314990/
It should be suitable for your task.

D
Drno, 2022-02-06
@Drno

You can use putty specifying the log/pass file
Or just type it in the batch file
Why do you need to restart the router?)

M
MaxKozlov, 2022-02-07
@MaxKozlov

If you can configure key authorization on your router, one ssh is enough for you.
Just add the key to the agent and run ssh [email protected] host command
. Invoke-SshCommand

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question