Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Automate switch config backup

Posted on 2016-11-28
3
69 Views
Last Modified: 2016-11-29
I have a list of switches that I want to copy the config from.  I have a script that I can copy the config from one of them.  Can you help me modify this for many switches? They are all the same model.  This script connects via telnet and saves the config to a tftp server.

<job>
<script language="VBScript">
Option Explicit
On Error Resume Next
Dim WshShell
set WshShell=CreateObject("WScript.Shell")
WshShell.run "cmd.exe"
WScript.Sleep 1000
WshShell.SendKeys "telnet 172.25.209.254 23"
WshShell.SendKeys ("{Enter}")
WScript.Sleep 1000
WshShell.SendKeys ("^Y")
WScript.Sleep 1000
WshShell.SendKeys ("EN")
WScript.Sleep 1000
WshShell.SendKeys ("{Enter}")
WScript.Sleep 3000
WshShell.SendKeys ("copy running-config tftp address 172.24.109.124 filename Backup2.txt")
WScript.Sleep 1000
WshShell.SendKeys ("{Enter}")
WScript.Sleep 1000
WshShell.SendKeys ("logout")
WScript.Sleep 1000
WshShell.SendKeys ("{Enter}")
WScript.Quit 
</script>
</job>

Open in new window

0
Comment
Question by:Roccat
  • 2
3 Comments
 
LVL 32

Accepted Solution

by:
Robberbaron (robr) earned 500 total points
ID: 41905259
all I have done is split the telnet code out into a Sub and then called it using different target and backupfiles
you could also consider a telnet app that lets you supply a command file as sendkeys is often unreliable.

Option Explicit

SaveConfig "172.25.209.254" "172.24.109.24" "backup254.txt"

SaveConfig "172.25.209.252" "172.24.109.24" "backup252.txt"


WScript.Quit

Sub SaveConfig(srcIP, destIP, destFile)
	On Error Resume Next
	Dim WshShell
	set WshShell=CreateObject("WScript.Shell")
	WshShell.run "cmd.exe"
	WScript.Sleep 1000
	'WshShell.SendKeys "telnet 172.25.209.254 23"  '---orig
	WshShell.SendKeys "telnet " & srcIP & " 23"
	WshShell.SendKeys ("{Enter}")
	WScript.Sleep 1000
	WshShell.SendKeys ("^Y")
	WScript.Sleep 1000
	WshShell.SendKeys ("EN")
	WScript.Sleep 1000
	WshShell.SendKeys ("{Enter}")
	WScript.Sleep 3000
	''WshShell.SendKeys ("copy running-config tftp address 172.24.109.124 filename Backup2.txt")   '' ---orig
	WshShell.SendKeys ("copy running-config tftp address " & destIP & " filename " & destFile)
	WScript.Sleep 1000
	WshShell.SendKeys ("{Enter}")
	WScript.Sleep 1000
	WshShell.SendKeys ("logout")
	WScript.Sleep 1000
	WshShell.SendKeys ("{Enter}")
End Sub
 

Open in new window

0
 
LVL 32

Expert Comment

by:Robberbaron (robr)
ID: 41905266
0
 

Author Closing Comment

by:Roccat
ID: 41905632
Thank you!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently I finished a vbscript that I thought I'd share.  It uses a text file with a list of server names to loop through and get various status reports, then writes them all into an Excel file.  Originally it was put together for our Altiris server…
Welcome, welcome!  If you are new to the series and haven't been following along, please take a brief moment to review the first three installments: Part 1 (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/A_266-VBScri…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

791 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question