Telnet Mass Configuration

Hi people

Someone has needed to connect and send many commands to a switch/router? My ideia would be a txt file with hosts list and other file with command.

I have part of that file but I need to inform the host and commands individually.

The script have a function named get-telnet and we call that like below:

Get-Telnet -RemoteHost "" -Commands "user","password","stuff","stuff","config","ip snmp-server community comm rw ","sntp client","no sntp server all","sntp server","clock timezone BR -3","end","copy runn startup" -OutputPath  "C:\Users\Scripts\output.txt" -WaitTime 1000

I found the function researching into web. Here the source:

Thank you for the help.
Thank you.

Not really sure what your question is?

Looking at your example do you mean that the remote hosts are in one file and the commands are in another?
And you want to grab those two files as a source to use the Get-Telnet with?
If so are there multiple hosts that are going to use the same commands or are they 1:1?

Hi Fredrik,

Thanks for your reply. Actually I need (would like to) get de hosts and commands both in a files, but, if that is not possible, to get the host list and the commands into script will be works fine.


Then, I suppose the simplest approach would be to have two files:

$RemoteHosts = Get-Content '//path/to/hosts/file.txt'
$Commands = Get-Content '//path/to/commands/file.txt'

$RemoteHosts | ForEach-Object {
    Get-Telnet -RemoteHost $_ -Commands $Commands

This assumes you are supplying the same commands to each remote host.