CODE BLOCK: SecureCRT Logon Scripts = Cisco ASA

Each week I aim to review a block of code, make improvements and present it to you here.

This week I’m reviewing my own SecureCRT Logon Script for Cisco ASA.

Please refer to my main article for information on these Logon scripts, such as installation, usage, and downloads:

Guide to Setting Up SecureCRT Logon Scripts-Here Are Mine! – 1System

I’ve refined these scripts over some time, and actually removed some code to clean these up and make them more readable.

Below are my Cisco ASA scripts, with the stock standard connect scripts (for direct access to the standalone device or context), and a separate set for access to the “System Context”, which bounces through the “Admin” context using “changeto context” commands.

Summary of the My Scripts!

I have 3 scripts for each type of device I connect to.

  • Script 1: “Connect” – Session connects, runs basic status information, and presents the logon prompt
  • Script 2: “Backup” – cfg_backup – Session connects, runs basic status information, completes backup, collect routing, logoff
  • Script 3: “Custom” – save_cmds – Session connects, runs basic status information=>Run pre-configured command blocks-Backup, show tech, server operational status, etc=>Logoff
The first set is for Direct Access.
The second set is for the System Context Access.
 
See them all below!

Direct Access

Direct Access => Script 1: “Connect” – Session connects, runs basic status information, and presents the logon prompt

Filename: MultiSessionLogin-Cisco_ASA.vbs

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

'~~~ SecureCRT VB logon script - Cisco ASA ~~~~~~~~~~~~~~~~~
' SecureCRT VB logon script for logging on to multiple servers
' AUTHOR: Brett Gardner - https://1system.online - LATEST RELEASE: 20210722
' CODE DISCLAIMER: https://1system.online/code-disclaimer/
' VENDOR & ORIGINAL BASE SCRIPT: VanDyke Software SecureCRT - https://www.vandyke.com/
' CUSTOMISED DEVICE TYPE: Cisco ASA
' TESTED: Version:
' Software Version: ASA Version 9.6(3)8 <context>
' Software Version: ASA Version 9.6(3)8
' Software Version: ASA Version 9.6(3)141 <context>
' Software Version: ASA Version 8.6(1)13
' Software Version: ASA Version 8.4(7)3

Sub Main()
    ' turn on synchronous mode
    crt.Screen.Synchronous = True

    ' login name
    crt.Screen.WaitForString "Username:"
    crt.Screen.Send "testuserid" & VbCr

    ' password
    crt.Screen.WaitForString "assword:"
    crt.Screen.Send "testpassword" & VbCr

	' find machine type
    crt.Screen.WaitForString "> "
    crt.Screen.Send "show version | i Cisco Adaptive Security Appliance" & VbCr
    crt.Screen.WaitForString "> "
'    row = crt.Screen.CurrentRow - 1
'    mach = Trim(crt.Screen.Get(row, 1, row, 33))
	
	' Run login informative commands
         crt.Screen.Send "enable" & VbCr
         crt.Screen.WaitForString "Password: "
         crt.Screen.Send "testpassword" & VbCr
		 crt.Screen.WaitForString "# "
		 crt.Screen.Send "show version | i Version" & VbCr
		 crt.Screen.WaitForString "# "
		 crt.Screen.Send "show clock" & VbCr
		 crt.Screen.WaitForString "# "
         crt.Screen.Send "show failover | grep host:" & VbCr
		 crt.Screen.WaitForString "# "
         crt.Screen.Send "show failover | grep Last|context" & VbCr
		 crt.Screen.WaitForString "# "
		 crt.Screen.Send "show version | i up " & VbCr
		 crt.Screen.WaitForString "# "
		 'Verify if configuration has been saved (do they match):
		 crt.Screen.Send "show running-config | include checksum:" & VbCr
		 crt.Screen.WaitForString "# "
		 crt.Screen.Send "show startup-config | include checksum:" & VbCr
		 crt.Screen.WaitForString "# "
		 crt.Screen.Send "show context" & VbCr
		 crt.Screen.WaitForString "# "
         crt.Screen.Send "show interface ip brief | exclude unassigned" & VbCr
		 crt.Screen.WaitForString "# "
		 crt.Screen.Send "show interface | i Interface.*line protocol is up" & VbCr
		 crt.Screen.WaitForString "# "
		 crt.Screen.Send "show environment | i Failed|Error" & VbCr
		 crt.Screen.WaitForString "# "

    ' turn off synchronous mode
    crt.Screen.Synchronous = False
End Sub

'~~~ SecureCRT VB logon script - Cisco ASA ~~~~~~~~~~~~~~~~~

System Context => Script 2: “Backup” – cfg_backup – Session connects, runs basic status information, completes backup, collect routing, logoff

Filename: MultiSessionLogin-Cisco_ASA-config_backup.vbs

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

'~~~ SecureCRT VB logon script - Cisco ASA ~~~~~~~~~~~~~~~~~
' SecureCRT VB logon script for logging on to multiple servers
' AUTHOR: Brett Gardner - https://1system.online - LATEST RELEASE: 20210722
' CODE DISCLAIMER: https://1system.online/code-disclaimer/
' VENDOR & ORIGINAL BASE SCRIPT: VanDyke Software SecureCRT - https://www.vandyke.com/
' CUSTOMISED DEVICE TYPE: Cisco ASA
' TESTED: Version:
' Software Version: ASA Version 9.6(3)8 <context>
' Software Version: ASA Version 9.6(3)8
' Software Version: ASA Version 9.6(3)141 <context>
' Software Version: ASA Version 8.6(1)13
' Software Version: ASA Version 8.4(7)3

Sub Main()
    ' turn on synchronous mode
    crt.Screen.Synchronous = True

    ' login name
    crt.Screen.WaitForString "Username:"
    crt.Screen.Send "testuserid" & VbCr

    ' password
    crt.Screen.WaitForString "assword:"
    crt.Screen.Send "testpassword" & VbCr

	' find machine type
    crt.Screen.WaitForString "> "
    crt.Screen.Send "show version | i Cisco Adaptive Security Appliance" & VbCr
    crt.Screen.WaitForString "> "
'	row = crt.Screen.CurrentRow - 1
'    mach = Trim(crt.Screen.Get(row, 1, row, 33))
	
	' Run login informative commands
         crt.Screen.Send "enable" & VbCr
         crt.Screen.WaitForString "Password: "
         crt.Screen.Send "testpassword" & VbCr
		 crt.Screen.WaitForString "# "
		 crt.Screen.Send "show version | i Version" & VbCr
		 crt.Screen.WaitForString "# "
		 crt.Screen.Send "show clock" & VbCr
		 crt.Screen.WaitForString "# "
         crt.Screen.Send "show failover | grep host:" & VbCr
		 crt.Screen.WaitForString "# "
         crt.Screen.Send "show failover | grep Last|context" & VbCr
		 crt.Screen.WaitForString "# "
         crt.Screen.Send "terminal pager 0" & VbCr
		 crt.Screen.WaitForString "# "
		 crt.Screen.Send "show version | i up " & VbCr
		 crt.Screen.WaitForString "# "
		 'Verify if configuration has been saved (do they match):
		 crt.Screen.Send "show running-config | include checksum:" & VbCr
		 crt.Screen.WaitForString "# "
		 crt.Screen.Send "show startup-config | include checksum:" & VbCr
		 crt.Screen.WaitForString "# "
		 crt.Screen.Send "show context" & VbCr
		 crt.Screen.WaitForString "# "
         crt.Screen.Send "show interface ip brief | exclude unassigned" & VbCr
		 crt.Screen.WaitForString "# "
		 crt.Screen.Send "show interface | i Interface.*line protocol is up" & VbCr
		 crt.Screen.WaitForString "# "
		 crt.Screen.Send "show environment | i Failed|Error" & VbCr
		 crt.Screen.WaitForString "# "
		 crt.Screen.Send "show conn count" & VbCr
		 crt.Screen.WaitForString "# "
         crt.Screen.Send "show failover" & VbCr
		 crt.Screen.WaitForString "# "
         crt.Screen.Send "more system:running-config | inc key" & VbCr
		 crt.Screen.WaitForString "# "
         crt.Screen.Send "show running-config" & VbCr
		 crt.Screen.WaitForString "# "
         crt.Screen.Send "show ospf neighbor" & VbCr
		 crt.Screen.WaitForString "# "
         crt.Screen.Send "show bgp neighbor" & VbCr
		 crt.Screen.WaitForString "# "
         crt.Screen.Send "show route" & VbCr
		 crt.Screen.WaitForString "# "
         crt.Screen.Send "exit" & VbCr

    ' turn off synchronous mode
    crt.Screen.Synchronous = False
End Sub

'~~~ SecureCRT VB logon script - Cisco ASA ~~~~~~~~~~~~~~~~~

System Context => Script 3: “Custom” – save_cmds – Session connects, runs basic status information=>Run pre-configured command blocks-Backup, show tech, server operational status, etc=>Logoff

Filename: MultiSessionLogin-Cisco_ASA-save_cmds.vbs

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

'~~~ SecureCRT VB logon script - Cisco ASA ~~~~~~~~~~~~~~~~~
' SecureCRT VB logon script for logging on to multiple servers
' AUTHOR: Brett Gardner - https://1system.online - LATEST RELEASE: 20210722
' CODE DISCLAIMER: https://1system.online/code-disclaimer/
' VENDOR & ORIGINAL BASE SCRIPT: VanDyke Software SecureCRT - https://www.vandyke.com/
' CUSTOMISED DEVICE TYPE: Cisco ASA
' TESTED: Version:
' Software Version: ASA Version 9.6(3)8 <context>
' Software Version: ASA Version 9.6(3)8
' Software Version: ASA Version 9.6(3)141 <context>
' Software Version: ASA Version 8.6(1)13
' Software Version: ASA Version 8.4(7)3

Sub Main()
    ' turn on synchronous mode
    crt.Screen.Synchronous = True

    ' login name
    crt.Screen.WaitForString "Username:"
    crt.Screen.Send "testuserid" & VbCr

    ' password
    crt.Screen.WaitForString "assword:"
    crt.Screen.Send "testpassword" & VbCr

	' find machine type
    crt.Screen.WaitForString "> "
    crt.Screen.Send "show version | i Cisco Adaptive Security Appliance" & VbCr
    crt.Screen.WaitForString "> "
	
	' Run login informative commands
         crt.Screen.Send "enable" & VbCr
         crt.Screen.WaitForString "Password: "
         crt.Screen.Send "testpassword" & VbCr
		 crt.Screen.WaitForString "# "
		 crt.Screen.Send "show version | i Version" & VbCr
		 crt.Screen.WaitForString "# "
		 crt.Screen.Send "show clock" & VbCr
		 crt.Screen.WaitForString "# "
         crt.Screen.Send "show failover | grep host:" & VbCr
		 crt.Screen.WaitForString "# "
         crt.Screen.Send "show failover | grep Last|context" & VbCr
		 crt.Screen.WaitForString "# "
         crt.Screen.Send "terminal pager 0" & VbCr
		 crt.Screen.WaitForString "# "
		 crt.Screen.Send "show version | i up " & VbCr
		 crt.Screen.WaitForString "# "
		 'Verify if configuration has been saved (do they match):
		 crt.Screen.Send "show running-config | include checksum:" & VbCr
		 crt.Screen.WaitForString "# "
		 crt.Screen.Send "show startup-config | include checksum:" & VbCr
		 crt.Screen.WaitForString "# "
		 crt.Screen.Send "show context" & VbCr
		 crt.Screen.WaitForString "# "
         crt.Screen.Send "show interface ip brief | exclude unassigned" & VbCr
		 crt.Screen.WaitForString "# "
		 crt.Screen.Send "show interface | i Interface.*line protocol is up" & VbCr
		 crt.Screen.WaitForString "# "
		 crt.Screen.Send "show environment | i Failed|Error" & VbCr
		 crt.Screen.WaitForString "# "
		 
		 ' ===== Custom commands to run==============
         crt.Screen.Send "show version" & VbCr
		 crt.Screen.WaitForString "# "

		' System configuration commands & routing
'        crt.Screen.Send "show run" & VbCr
         crt.Screen.Send "show run all" & VbCr
'         crt.Screen.Send "more system:running-config" & VbCr	'Not Virtual Context-System Context or Standalone
		 crt.Screen.WaitForString "# "
         crt.Screen.Send "show ospf neighbor" & VbCr
		 crt.Screen.WaitForString "# "
         crt.Screen.Send "show bgp neighbor" & VbCr
		 crt.Screen.WaitForString "# "
         crt.Screen.Send "show route" & VbCr
		 crt.Screen.WaitForString "# "

		' Interface and failover
         crt.Screen.Send "show interface ip brief" & VbCr
		 crt.Screen.WaitForString "# "
         crt.Screen.Send "show interface summary" & VbCr
		 crt.Screen.WaitForString "# "
         crt.Screen.Send "show interface detail" & VbCr
		 crt.Screen.WaitForString "# "
         crt.Screen.Send "show arp" & VbCr
		 crt.Screen.WaitForString "# "
         crt.Screen.Send "show failover state" & VbCr	'Not Virtual Context-System Context or Standalone
		 crt.Screen.WaitForString "# "
         crt.Screen.Send "show failover statistics" & VbCr	'Not Virtual Context-System Context or Standalone
		 crt.Screen.WaitForString "# "
         crt.Screen.Send "show failover" & VbCr
		 crt.Screen.WaitForString "# "
         crt.Screen.Send "show asp drop" & VbCr
		 crt.Screen.WaitForString "# "

		' System performance commands
			'Part 1 - Issue this first, before Part 2 10 minutes later
'				crt.Screen.Send "clear traffic" & VbCr
'				crt.Screen.WaitForString "# "
			'Part 2
				crt.Screen.Send "show xlate" & VbCr	'Not System Context
				crt.Screen.WaitForString "# "
				crt.Screen.Send "show memory detail" & VbCr
				crt.Screen.WaitForString "# "
				crt.Screen.Send "show processes cpu-hog" & VbCr	'Not Virtual Context-System Context or Standalone
				crt.Screen.WaitForString "# "
				crt.Screen.Send "show processes memory" & VbCr	'Not Virtual Context-System Context or Standalone
				crt.Screen.WaitForString "# "
				crt.Screen.Send "show cpu usage" & VbCr
				crt.Screen.WaitForString "# "
				crt.Screen.Send "show perfmon" & VbCr	'Virtual Context or Standalone-Not System Context
				crt.Screen.WaitForString "# "
				crt.Screen.Send "show blocks" & VbCr
				crt.Screen.WaitForString "# "
				' For accurate results, issue the clear traffic command first and then wait 1-10 minutes before you issue the show traffic command.
				crt.Screen.Send "show traffic" & VbCr
				crt.Screen.WaitForString "# "

		' Specific troubleshooting commands for system issue
				crt.Screen.Send "show blocks old" & VbCr
				crt.Screen.WaitForString "# "
				' Very big dupmp - Takes some time to run on the system context. Can run on virtual context, but cannot use redirect command
				'crt.Screen.Send "show blocks pool 1550 dump | redirect disk0:blckpool1550dump" & VbCr 'Not Virtual Context-System Context or Standalone
				'crt.Screen.WaitForString "# "
				crt.Screen.Send "show blocks old dump | redirect disk0:blckolddumpƒ" & VbCr
				crt.Screen.WaitForString "# "
				crt.Screen.Send "show blocks queue history detail" & VbCr
				crt.Screen.WaitForString "# "
				crt.Screen.Send "show blocks queue history core-local" & VbCr
				crt.Screen.WaitForString "# "
				crt.Screen.Send "show blocks old core-local" & VbCr
				crt.Screen.WaitForString "# "
				crt.Screen.Send "show blocks exhaustion snapshot" & VbCr
				crt.Screen.WaitForString "# "
				crt.Screen.Send "show block assigned" & VbCr
				crt.Screen.WaitForString "# "

		' Cisco show tech
        crt.Screen.Send "show tech" & VbCr
		crt.Screen.WaitForString "# "

        crt.Screen.Send "exit" & VbCr

    ' turn off synchronous mode
    crt.Screen.Synchronous = False
End Sub

'~~~ SecureCRT VB logon script - Cisco ASA ~~~~~~~~~~~~~~~~~

Access to the System Context

System Context => Script 1: “Connect” – Session connects, runs basic status information, and presents the logon prompt

Filename: MultiSessionLogin-Cisco_ASA-System_Ctx.vbs

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

'~~~ SecureCRT VB logon script - Cisco ASA ~~~~~~~~~~~~~~~~~
' SecureCRT VB logon script for logging on to multiple servers
' AUTHOR: Brett Gardner - https://1system.online - LATEST RELEASE: 20210722
' CODE DISCLAIMER: https://1system.online/code-disclaimer/
' VENDOR & ORIGINAL BASE SCRIPT: VanDyke Software SecureCRT - https://www.vandyke.com/
' CUSTOMISED DEVICE TYPE: Cisco ASA
' TESTED: Version:
' Software Version: ASA Version 9.6(3)8 <context>
' Software Version: ASA Version 9.6(3)8
' Software Version: ASA Version 9.6(3)141 <context>
' Software Version: ASA Version 8.6(1)13
' Software Version: ASA Version 8.4(7)3

Sub Main()
    ' turn on synchronous mode
    crt.Screen.Synchronous = True

    ' login name
    crt.Screen.WaitForString "Username:"
    crt.Screen.Send "testuserid" & VbCr

    ' password
    crt.Screen.WaitForString "assword:"
    crt.Screen.Send "testpassword" & VbCr

	' find machine type
    crt.Screen.WaitForString "> "
    crt.Screen.Send "show version | i Cisco Adaptive Security Appliance" & VbCr
    crt.Screen.WaitForString "> "
'	row = crt.Screen.CurrentRow - 1
'    mach = Trim(crt.Screen.Get(row, 1, row, 33))

	' Run login informative commands
         crt.Screen.Send "enable" & VbCr
         crt.Screen.WaitForString "Password: "
         crt.Screen.Send "testpassword" & VbCr
		 crt.Screen.WaitForString "# "
		 crt.Screen.Send "show version | i Version" & VbCr
		 crt.Screen.WaitForString "# "

			' Change context to system
			crt.Screen.Send "changeto system" & VbCr
			crt.Screen.WaitForString "# "
	
		 crt.Screen.Send "show clock" & VbCr
		 crt.Screen.WaitForString "# "
         crt.Screen.Send "show failover | grep host:" & VbCr
		 crt.Screen.WaitForString "# "
         crt.Screen.Send "show failover | grep Last|context" & VbCr
		 crt.Screen.WaitForString "# "
		 crt.Screen.Send "show version | i up " & VbCr
		 crt.Screen.WaitForString "# "
		 'Verify if configuration has been saved (do they match):
		 crt.Screen.Send "show running-config | include checksum:" & VbCr
		 crt.Screen.WaitForString "# "
		 crt.Screen.Send "show startup-config | include checksum:" & VbCr
		 crt.Screen.WaitForString "# "
		 crt.Screen.Send "show context" & VbCr
		 crt.Screen.WaitForString "# "
         crt.Screen.Send "show interface ip brief | exclude unassigned" & VbCr
		 crt.Screen.WaitForString "# "
		 crt.Screen.Send "show interface | i Interface.*line protocol is up" & VbCr
		 crt.Screen.WaitForString "# "
		 crt.Screen.Send "show environment | i Failed|Error" & VbCr
		 crt.Screen.WaitForString "# "
    'End If

    ' turn off synchronous mode
    crt.Screen.Synchronous = False
End Sub

'~~~ SecureCRT VB logon script - Cisco ASA ~~~~~~~~~~~~~~~~~

System Context => Script 2: “Backup” – cfg_backup – Session connects, runs basic status information, completes backup, collect routing, logoff

Filename: MultiSessionLogin-Cisco_ASA-System_Ctx-config_backup.vbs

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

'~~~ SecureCRT VB logon script - Cisco ASA ~~~~~~~~~~~~~~~~~
' SecureCRT VB logon script for logging on to multiple servers
' AUTHOR: Brett Gardner - https://1system.online - LATEST RELEASE: 20210722
' CODE DISCLAIMER: https://1system.online/code-disclaimer/
' VENDOR & ORIGINAL BASE SCRIPT: VanDyke Software SecureCRT - https://www.vandyke.com/
' CUSTOMISED DEVICE TYPE: Cisco ASA
' TESTED: Version:
' Software Version: ASA Version 9.6(3)8 <context>
' Software Version: ASA Version 9.6(3)8
' Software Version: ASA Version 9.6(3)141 <context>
' Software Version: ASA Version 8.6(1)13
' Software Version: ASA Version 8.4(7)3

Sub Main()
    ' turn on synchronous mode
    crt.Screen.Synchronous = True

    ' login name
    crt.Screen.WaitForString "Username:"
    crt.Screen.Send "testuserid" & VbCr

    ' password
    crt.Screen.WaitForString "assword:"
    crt.Screen.Send "testpassword" & VbCr

	' find machine type
    crt.Screen.WaitForString "> "
    crt.Screen.Send "show version | i Cisco Adaptive Security Appliance" & VbCr
    crt.Screen.WaitForString "> "
'	row = crt.Screen.CurrentRow - 1
'    mach = Trim(crt.Screen.Get(row, 1, row, 33))
	
	' Run login informative commands
         crt.Screen.Send "enable" & VbCr
         crt.Screen.WaitForString "Password: "
         crt.Screen.Send "testpassword" & VbCr
		 crt.Screen.WaitForString "# "
		 crt.Screen.Send "show version | i Version" & VbCr
		 crt.Screen.WaitForString "# "

			' Change context to system
			crt.Screen.Send "changeto system" & VbCr
			crt.Screen.WaitForString "# "

		 crt.Screen.Send "show clock" & VbCr
		 crt.Screen.WaitForString "# "
         crt.Screen.Send "show failover | grep host:" & VbCr
		 crt.Screen.WaitForString "# "
         crt.Screen.Send "show failover | grep Last|context" & VbCr
		 crt.Screen.WaitForString "# "
         crt.Screen.Send "terminal pager 0" & VbCr
		 crt.Screen.WaitForString "# "
		 crt.Screen.Send "show version | i up " & VbCr
		 crt.Screen.WaitForString "# "
		 'Verify if configuration has been saved (do they match):
		 crt.Screen.Send "show running-config | include checksum:" & VbCr
		 crt.Screen.WaitForString "# "
		 crt.Screen.Send "show startup-config | include checksum:" & VbCr
		 crt.Screen.WaitForString "# "
		 crt.Screen.Send "show context" & VbCr
		 crt.Screen.WaitForString "# "
         crt.Screen.Send "show interface ip brief | exclude unassigned" & VbCr
		 crt.Screen.WaitForString "# "
		 crt.Screen.Send "show interface | i Interface.*line protocol is up" & VbCr
		 crt.Screen.WaitForString "# "
		 crt.Screen.Send "show environment | i Failed|Error" & VbCr
		 crt.Screen.WaitForString "# "
         crt.Screen.Send "more system:running-config | inc key" & VbCr
		 crt.Screen.WaitForString "# "
         crt.Screen.Send "show conn count" & VbCr
		 crt.Screen.WaitForString "# "
         crt.Screen.Send "show failover" & VbCr
		 crt.Screen.WaitForString "# "
         crt.Screen.Send "show running" & VbCr
		 crt.Screen.WaitForString "# "
         crt.Screen.Send "exit" & VbCr

    ' turn off synchronous mode
    crt.Screen.Synchronous = False
End Sub

'~~~ SecureCRT VB logon script - Cisco ASA ~~~~~~~~~~~~~~~~~

System Context => Script 3: “Custom” – save_cmds – Session connects, runs basic status information=>Run pre-configured command blocks-Backup, show tech, server operational status, etc=>Logoff

Filename: MultiSessionLogin-Cisco_ASA-System_Ctx-save_cmds.vbs

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

'~~~ SecureCRT VB logon script - Cisco ASA ~~~~~~~~~~~~~~~~~
' SecureCRT VB logon script for logging on to multiple servers
' AUTHOR: Brett Gardner - https://1system.online - LATEST RELEASE: 20210722
' CODE DISCLAIMER: https://1system.online/code-disclaimer/
' VENDOR & ORIGINAL BASE SCRIPT: VanDyke Software SecureCRT - https://www.vandyke.com/
' CUSTOMISED DEVICE TYPE: Cisco ASA
' TESTED: Version:
' Software Version: ASA Version 9.6(3)8 <context>
' Software Version: ASA Version 9.6(3)8
' Software Version: ASA Version 9.6(3)141 <context>
' Software Version: ASA Version 8.6(1)13
' Software Version: ASA Version 8.4(7)3

Sub Main()
    ' turn on synchronous mode
    crt.Screen.Synchronous = True

    ' login name
    crt.Screen.WaitForString "Username:"
    crt.Screen.Send "testuserid" & VbCr

    ' password
    crt.Screen.WaitForString "assword:"
    crt.Screen.Send "testpassword" & VbCr

	' find machine type
    crt.Screen.WaitForString "> "
    crt.Screen.Send "show version | i Cisco Adaptive Security Appliance" & VbCr
    crt.Screen.WaitForString "> "
'	row = crt.Screen.CurrentRow - 1
'    mach = Trim(crt.Screen.Get(row, 1, row, 33))
	
	' Run login informative commands
         crt.Screen.Send "enable" & VbCr
         crt.Screen.WaitForString "Password: "
         crt.Screen.Send "testpassword" & VbCr
		 crt.Screen.WaitForString "# "
		 crt.Screen.Send "show version | i Version" & VbCr
		 crt.Screen.WaitForString "# "

			' Change context to system
			crt.Screen.Send "changeto system" & VbCr
			crt.Screen.WaitForString "# "

		 crt.Screen.Send "show clock" & VbCr
		 crt.Screen.WaitForString "# "
         crt.Screen.Send "show failover | grep host:" & VbCr
		 crt.Screen.WaitForString "# "
         crt.Screen.Send "show failover | grep Last|context" & VbCr
		 crt.Screen.WaitForString "# "
         crt.Screen.Send "terminal pager 0" & VbCr
		 crt.Screen.WaitForString "# "
		 crt.Screen.Send "show version | i up " & VbCr
		 crt.Screen.WaitForString "# "
		 'Verify if configuration has been saved (do they match):
		 crt.Screen.Send "show running-config | include checksum:" & VbCr
		 crt.Screen.WaitForString "# "
		 crt.Screen.Send "show startup-config | include checksum:" & VbCr
		 crt.Screen.WaitForString "# "
		 crt.Screen.Send "show context" & VbCr
		 crt.Screen.WaitForString "# "
         crt.Screen.Send "show interface ip brief | exclude unassigned" & VbCr
		 crt.Screen.WaitForString "# "
		 crt.Screen.Send "show interface | i Interface.*line protocol is up" & VbCr
		 crt.Screen.WaitForString "# "
		 crt.Screen.Send "show environment | i Failed|Error" & VbCr
		 crt.Screen.WaitForString "# "
		 
		 ' ===== Custom commands to run==============
         crt.Screen.Send "show version" & VbCr
		 crt.Screen.WaitForString "# "

		' System configuration commands & routing
'         crt.Screen.Send "show run" & VbCr
'         crt.Screen.Send "show run all" & VbCr
         crt.Screen.Send "more system:running-config" & VbCr	'Not Virtual Context-System Context or Standalone
		 crt.Screen.WaitForString "# "
         crt.Screen.Send "show ospf neighbor" & VbCr
		 crt.Screen.WaitForString "# "
         crt.Screen.Send "show bgp neighbor" & VbCr
		 crt.Screen.WaitForString "# "
         crt.Screen.Send "show route" & VbCr
		 crt.Screen.WaitForString "# "

		' Interface and failover
         crt.Screen.Send "show interface ip brief" & VbCr
		 crt.Screen.WaitForString "# "
         crt.Screen.Send "show interface summary" & VbCr
		 crt.Screen.WaitForString "# "
         crt.Screen.Send "show interface detail" & VbCr
		 crt.Screen.WaitForString "# "
         crt.Screen.Send "show arp" & VbCr
		 crt.Screen.WaitForString "# "
         crt.Screen.Send "show failover state" & VbCr	'Not Virtual Context-System Context or Standalone
		 crt.Screen.WaitForString "# "
         crt.Screen.Send "show failover statistics" & VbCr	'Not Virtual Context-System Context or Standalone
		 crt.Screen.WaitForString "# "
         crt.Screen.Send "show failover" & VbCr
		 crt.Screen.WaitForString "# "
         crt.Screen.Send "show asp drop" & VbCr
		 crt.Screen.WaitForString "# "

		' System performance commands
			'Part 1 - Issue this first, before Part 2 10 minutes later
'				crt.Screen.Send "clear traffic" & VbCr
'				crt.Screen.WaitForString "# "
			'Part 2
				crt.Screen.Send "show xlate" & VbCr	'Not System Context
				crt.Screen.WaitForString "# "
				crt.Screen.Send "show memory detail" & VbCr
				crt.Screen.WaitForString "# "
				crt.Screen.Send "show processes cpu-hog" & VbCr	'Not Virtual Context-System Context or Standalone
				crt.Screen.WaitForString "# "
				crt.Screen.Send "show processes memory" & VbCr	'Not Virtual Context-System Context or Standalone
				crt.Screen.WaitForString "# "
				crt.Screen.Send "show cpu usage" & VbCr
				crt.Screen.WaitForString "# "
				crt.Screen.Send "show perfmon" & VbCr	'Virtual Context or Standalone-Not System Context
				crt.Screen.WaitForString "# "
				crt.Screen.Send "show blocks" & VbCr
				crt.Screen.WaitForString "# "
				' For accurate results, issue the clear traffic command first and then wait 1-10 minutes before you issue the show traffic command.
				crt.Screen.Send "show traffic" & VbCr
				crt.Screen.WaitForString "# "

		' Specific troubleshooting commands for system issue
				crt.Screen.Send "show blocks old" & VbCr
				crt.Screen.WaitForString "# "
				' Very big dupmp - Takes some time to run on the system context. Can run on virtual context, but cannot use redirect command
				'crt.Screen.Send "show blocks pool 1550 dump | redirect disk0:blckpool1550dump" & VbCr 'Not Virtual Context-System Context or Standalone
				'crt.Screen.WaitForString "# "
				crt.Screen.Send "show blocks old dump | redirect disk0:blckolddumpƒ" & VbCr
				crt.Screen.WaitForString "# "
				crt.Screen.Send "show blocks queue history detail" & VbCr
				crt.Screen.WaitForString "# "
				crt.Screen.Send "show blocks queue history core-local" & VbCr
				crt.Screen.WaitForString "# "
				crt.Screen.Send "show blocks old core-local" & VbCr
				crt.Screen.WaitForString "# "
				crt.Screen.Send "show blocks exhaustion snapshot" & VbCr
				crt.Screen.WaitForString "# "
				crt.Screen.Send "show block assigned" & VbCr
				crt.Screen.WaitForString "# "

		' Cisco show tech
		crt.Screen.Send "show tech" & VbCr
		crt.Screen.WaitForString "# "

        crt.Screen.Send "exit" & VbCr

    ' turn off synchronous mode
    crt.Screen.Synchronous = False
End Sub

'~~~ SecureCRT VB logon script - Cisco ASA ~~~~~~~~~~~~~~~~~

Please let me know what you think!  Suggest improvements or join my site to get future updates.

Leave a Reply