View Single Post
Old 04-11-2018, 08:45 AM
respite respite is offline
Registered User
Join Date: May 2017
Posts: 6
Script only running on a few hosts at a time

Hello again,

I've been tasked with polling all of our branch Cisco switches for their iOS version and deploy a patch to them after.

My problem is, for whatever reason, my script seems to only want to run on two "vHosts" at once before just sitting there and not obeying the "crt.Session.disconnect" command. When the script stops, I have to manually disconnect the session, then the script will proceed. Any ideas? Script is below.

*Note: there will be many more hosts than just the ones listed, about 900 more*

#$language = "VBScript"
#$interface = "1.0"

crt.Screen.Synchronous = True

on error resume next

Dim vHosts(1000)

vHosts(0) = ""
vHosts(1) = ""
vHosts(2) = ""
vHosts(3) = ""
vHosts(4) = ""
vHosts(5) = ""
vHosts(6) = ""

For Each strHost In vHosts
 If strHost = "" Then Exit For

 ' Make sure we are disconnected before attempting a connection
 If crt.Session.Connected Then crt.Session.Disconnect
  Dim logfile
  logfile = "C:\Users\nmorra\Documents\Scripts\logs\switch-version.log"
  crt.Session.LogFileName = logfile
  crt.Session.Log True, True

 ' Connect to the next host
 crt.Session.Connect "/SSH2 /L * /PASSWORD * " & strHost

	crt.Screen.WaitForString "#"
	crt.Screen.Send "sh version | inc Cisco IOS Software" & chr(13)
	crt.Screen.WaitForString "#"
	crt.Screen.Send "quit" & chr(13)
Reply With Quote