Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Automate switch config backup

Posted on 2016-11-28
3
Medium Priority
?
98 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
[X]
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
  • 2
3 Comments
 
LVL 32

Accepted Solution

by:
Robberbaron (robr) earned 2000 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

In this article we want to have a look at the directory attributes which are used by Microsoft to store the so called Security Identifiers (SID). These SIDs plays an important role in delegating and granting permissions and in authentication of trus…
Welcome back!  My apologies for taking so long to write part two of this series; it's been a long time coming!  As I promised in Part 1, this article will focus on how to locate those elusive AD properties that you are searching for.  Why is this us…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

730 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