Telnet Mass Configuration

Welcome Forums General PowerShell Q&A Telnet Mass Configuration

This topic contains 3 replies, has 3 voices, and was last updated by

 
Participant
6 months, 3 weeks ago.

  • Author
    Posts
  • #99381

    Participant
    Points: 0
    Rank: Member

    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 "1.1.1.1" -Commands "user","password","stuff","stuff","config","ip snmp-server community comm rw ","sntp client","no sntp server all","sntp server 2.2.2.2","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: https://superuser.com/questions/1209098/issue-with-telnet-connection-through-get-telnet-script

    Thank you for the help.
    Thank you.

  • #99391

    Participant
    Points: 141
    Helping Hand
    Rank: Participant

    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?

    • #99396

      Participant
      Points: 0
      Rank: Member

      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.

      rc.

  • #99399

    Participant
    Points: 160
    Helping Hand
    Rank: Participant

    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.

The topic ‘Telnet Mass Configuration’ is closed to new replies.