ORIGINALLY POSTED BY TALEN FOR THETAZZONE/TAZFORUM HERE

Do not use, republish, in whole or in part, without the consent of the Author. TheTAZZone policy is that Authors retain the rights to the work they submit and/or post…we do not sell, publish, transmit, or have the right to give permission for such…TheTAZZone merely retains the right to use, retain, and publish submitted work within it’s Network

Please refer to the original post as not all the script may be visible here.

I manage a *lot* of network devices (all of them Cisco), so I maintain a repository of configurations which are all text files. I devised a method to keep all the configurations straight, and essentially maintain a kind of change control system.

I have a folder on my system named “Network Device Configurations”. Inside this folder are folders named with the hostname of each individual device. Each device folder has subfolders named by year (e.g. 2008). Each year subfolder has twelve subfolders, 01 through 12, for each month of the year. Rather than create the folder structure by hand, I use the following script:

Code: Select all
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set WshShell = WScript.CreateObject("WScript.Shell")

strDeviceName = InputBox("Enter the device name:", "Network Device Name")

If strDeviceName = "" Then
WshShell.Popup "You must provide a device name!", 10, "Missing Device " & _
"Name!", 48
WScript.Quit
End If

' * * * Change This Line ! ! ! * * *
strTopLevelFldr = "C:\PathToYour\Network Device Configurations\" & _
strDeviceName
strYFldr = strTopLevelFldr & "\" & Year(Date)

If objFSO.FolderExists (strTopLevelFldr) Then
WshShell.Popup "Top level folder already exists and will not be created." & _
vbCrLf, 10, "Folder Exists!", 48
subCreateYFldr
Else
WshShell.Popup "Folder does not already exist and will be created." & _
vbCrLf, 10, "New Folder", 48
Set objFldr = objFSO.CreateFolder(strTopLevelFldr)
subCreateYFldr
End If

Sub subCreateYFldr
If objFSO.FolderExists (strYFldr) Then
WScript.Quit
Else
Set objFldr = objFSO.CreateFolder(strYFldr)
subCreateMFldrs
End If
End Sub

Sub subCreateMFldrs
intM = 1

Do Until intM = 10
strMFldr = strYFldr & "\0" & intM
Set objFldr = objFSO.CreateFolder(strMFldr)
intM = intM + 1
Loop

Do Until intM = 13
strMFldr = strYFldr & "\" & intM
Set objFldr = objFSO.CreateFolder(strMFldr)
intM = intM + 1
Loop
End Sub

WshShell.Popup "Creation of:" & vbCrLf & vbCrLf & strTopLevelFldr & _
vbCrLf & vbCrLf &   "and all subfolders complete.", 10, _
"Folders Created!", 48

Then, any and every time I edit a device configuration, the first thing I do is take a copy of the current configuration and save it to the appropriate folder and name it using the following convention:

Code: Select all
YYYYMMDD HHMM DeviceName Backup Config.TXT

When I’m done making any changes, I’ll save the new file using a similar convention:

Code: Select all
YYYYMMDD HHMM DeviceName New ACL.TXT

Generally using short, but descriptive nomenclature for whatever change I made. I also rarely save the entire config in this file, but usually just the changes made.

This is helpful in that I can review historical configurations and see what changes were made when (and the above naming convention keeps everything organized in chronological order when sorted by name).

By admin

Former Freehand Freelance Graphic Illustrator... been online since 2004 ( late starter ), blogging since 2005, presently writing a suspense-thriller e-book that began as a screenplay.

Leave a Reply

Your email address will not be published. Required fields are marked *