Network automation with no tools…?
Tools are great in network automation. As an architect, I have been taught to think outside the box. Sometimes, the tool or workflow we need might not exist, or it might not be available in the environment we are working in.
We still have a requirement to deliver. This is where understanding how things work becomes useful. We can take the capabilities already available and build something that meets the requirement.
For this example, let’s keep it simple. We need to connect to 20 switches, pull interface information and put the results into one text file. We will use a Windows batch script and Plink to do this.
This is the sort of script people often describe as DOS based. Technically, we are using a .bat file running under Windows Command Prompt.
Start with the requirement
Before writing the script, we need to understand what we want it to do. In this example, we want to collect the interface status from each switch, identify which switch the output belongs to and keep connection errors visible in the report.
We will connect to the switches sequentially. This makes the output easier to follow and keeps the example straightforward. The switch commands in this article are for Cisco Nexus switches running NX-OS.
What is Plink
Most network engineers will be familiar with PuTTY. We open it, enter the management IP address of a switch and start an SSH session to run our commands.
Plink is the command line connection tool supplied with PuTTY. It allows us to establish an SSH connection and run a remote command from Command Prompt or a script. In our example, the batch script calls Plink for each switch and writes the returned output to a text file. [1]
PuTTY is common in network environments, so this is a useful place to start when looking at what is already available. The standard Windows PuTTY installer includes Plink alongside the other PuTTY utilities. If that package is installed on your workstation or management server, you may already have Plink available. [2]
There is one detail to check. A standalone copy of putty.exe does not include plink.exe. An organisation may also use a customised deployment containing only selected utilities. Check the installation folder before assuming it is there.
On a typical 64-bit Windows installation, you can check the usual location by running:
“C:Program FilesPuTTYplink.exe” -V
If Plink is installed there, this displays its version. If the file is not found, check your organisation’s installation location. You can also run where plink.exe to check whether it is available through the Windows PATH.
For me, this is a good example of thinking outside the box. We may already have a useful automation capability sitting alongside a tool we use regularly.
Prepare the files
Create a folder called C:NetworkCollection and place a copy of plink.exe inside it, using the existing installation where available. We will add two more files: switches.txt and collect-switches.bat. If Plink is not installed, obtain it through your organisation’s software process or from the official PuTTY download page. [2]
In switches.txt, put one management IP address on each line. For this example, we will use the following 20 addresses. Replace these with your own switch management addresses.
192.168.0.1
192.168.0.2
192.168.0.3
192.168.0.4
192.168.0.5
192.168.0.6
192.168.0.7
192.168.0.8
192.168.0.9
192.168.0.10
192.168.0.11
192.168.0.12
192.168.0.13
192.168.0.14
192.168.0.15
192.168.0.16
192.168.0.17
192.168.0.18
192.168.0.19
192.168.0.20
Using a separate file means we can change the switch list without changing the script.
Set up SSH authentication
The account used in this example is netops. It needs permission to run the collection commands on each switch.
Configure public key authentication for that account on the switches, then load the corresponding private key into Pageant, the PuTTY authentication agent. If the key has a passphrase, enter it when loading the key. The script can then use the loaded key without storing a password in the batch file. [5]
Before automating the connections, connect to each switch manually using PuTTY or Plink. Verify its SSH host key fingerprint against a trusted record and accept it once verified. Do this under the same Windows account that will run the script. Plink can then use the cached host keys. [1]
Test one switch first from Command Prompt. Run this from C:NetworkCollection:
plink.exe -ssh -batch -agent -l netops 192.168.0.1 “terminal length 0 ; show interface status”
The first command disables pagination for the session. The second collects the interface status. NX-OS supports separating CLI commands with a semicolon. This command sequence needs to be checked on the NX-OS release you are using before running it across the full list. [3]
Create the batch script
Save the following as collect-switches.bat in the same folder as plink.exe and switches.txt.
@echo off
setlocal
set “PLINK_EXE=%~dp0plink.exe”
set “SWITCH_LIST=%~dp0switches.txt”
set “REPORT_FILE=%~dp0switch-report.txt”
set “SWITCH_USER=netops”
if not exist “%PLINK_EXE%” (
echo ERROR: plink.exe was not found.
exit /b 1
)
if not exist “%SWITCH_LIST%” (
echo ERROR: switches.txt was not found.
exit /b 1
)
> “%REPORT_FILE%” echo Network collection – %DATE% %TIME%
for /F “usebackq eol=# delims=” %%S in (“%SWITCH_LIST%”) do (
echo Collecting from %%S…
>> “%REPORT_FILE%” echo(
>> “%REPORT_FILE%” echo ===== Switch %%S =====
“%PLINK_EXE%” -ssh -batch -agent ^
-l “%SWITCH_USER%” %%S ^
“terminal length 0 ; show interface status” ^
<nul >> “%REPORT_FILE%” 2>&1
if errorlevel 1 (
>> “%REPORT_FILE%” echo [ERROR] SSH collection failed.
)
)
echo Collection finished. Review “%REPORT_FILE%”.
endlocal
Understand what the script is doing
The %~dp0 variable points to the folder containing the batch file. This allows the script to locate Plink, the switch list and the report regardless of the current working directory.
The for /F loop reads one entry at a time from switches.txt. Blank lines are skipped, and lines beginning with # are treated as comments. The same approach works with a list of 20 switches or a different number of entries. [4]
For each switch, we write a heading into the report and then start the SSH connection. The -ssh option selects SSH, -agent allows authentication through Pageant and -l supplies the username. The -batch option prevents Plink from stopping for connection or authentication prompts. An unknown host key or authentication problem causes the connection to fail instead. [1]
The >> operator appends output to the report. The 2>&1 part sends error messages to the same file, so connection failures appear under the relevant switch heading. If Plink returns a nonzero exit status, the script adds an error marker and moves to the next entry.
The first write uses >, which replaces the previous report when a new collection starts. If you need to retain previous collections, use a separate report filename for each run.
Run the collection and review the report
Open Command Prompt and run:
cd /d C:NetworkCollection
collect-switches.bat
The script prints a collection message for each address as it reaches that entry. When the loop finishes, open switch-report.txt in the same folder.
Example console output
The following is illustrative output for a run that reaches all 20 entries. The collection messages show which address the script is processing. The interface data is written to the report file.
C:NetworkCollection>collect-switches.bat
Collecting from 192.168.0.1…
Collecting from 192.168.0.2…
Collecting from 192.168.0.3…
Collecting from 192.168.0.4…
Collecting from 192.168.0.5…
Collecting from 192.168.0.6…
Collecting from 192.168.0.7…
Collecting from 192.168.0.8…
Collecting from 192.168.0.9…
Collecting from 192.168.0.10…
Collecting from 192.168.0.11…
Collecting from 192.168.0.12…
Collecting from 192.168.0.13…
Collecting from 192.168.0.14…
Collecting from 192.168.0.15…
Collecting from 192.168.0.16…
Collecting from 192.168.0.17…
Collecting from 192.168.0.18…
Collecting from 192.168.0.19…
Collecting from 192.168.0.20…
Collection finished. Review “C:NetworkCollectionswitch-report.txt”.
Example report contents
Open switch-report.txt to review the collected data. The abbreviated example below shows two switch sections with representative NX-OS interface output. The interface names and values are illustrative; the actual output depends on your switches and software release. The report timestamp follows the Windows date and time settings.
Network collection – 20/11/2026 20:00:00.00
===== Switch 192.168.0.1 =====
Port Name Status Vlan Duplex Speed Type
Eth1/1 CORE-01 connected trunk full 10G 10Gbase-SR
Eth1/2 APP-SERVER-01 connected 110 full 10G 10Gbase-SR
Eth1/3 APP-SERVER-02 connected 110 full 10G 10Gbase-SR
===== Switch 192.168.0.2 =====
Port Name Status Vlan Duplex Speed Type
Eth1/1 CORE-02 connected trunk full 10G 10Gbase-SR
Eth1/2 DB-SERVER-01 connected 120 full 10G 10Gbase-SR
Eth1/3 DB-SERVER-02 connected 120 full 10G 10Gbase-SR
The script adds the switch headings. The switch supplies the interface output beneath each heading. This allows us to keep the data from all 20 switches in one file and still identify where each section came from.
Each switch should have a heading followed by its interface information or connection error. Check that all 20 switch headings are present and review the output beneath each one. A completed SSH session alone does not prove that the command was authorised or returned the information we expected. CLI errors can also appear as ordinary output.
Collect Security policy rules from a Palo Alto firewall
We can apply the same approach to a Palo Alto firewall. For this example, the requirement is to collect the running Security policy from a firewall with management IP address 192.168.0.101.
The PAN-OS operational command is show running security-policy. It provides the running Security policy view, including applicable policy pushed from Panorama. This is useful when reviewing the rules present on the managed firewall. It does not export uncommitted candidate changes or every type of policy. [6]
Use the same SSH key authentication and verified host key approach described earlier. The netops account must also have permission to run the PAN-OS commands below. This example assumes a single virtual system.
Create the Palo Alto command file
Save the following as paloalto-commands.txt in C:NetworkCollection. We send these commands as separate lines in a terminal session, rather than reusing the NX-OS command string.
set cli scripting-mode on
set cli pager off
show running security-policy
exit
The scripting setting supports scripted CLI input. Disabling the pager allows the policy output to continue without waiting for a key press. The final command closes the session. These are operational commands; no policy edit or commit is required. [7] [9]
Create the Palo Alto collection script
Save the following as collect-paloalto.bat beside Plink and the command file.
@echo off
setlocal
set “FW_IP=192.168.0.101”
set “FW_USER=netops”
set “FW_REPORT=%~dp0paloalto-security-rules.txt”
if not exist “%~dp0plink.exe” (
echo ERROR: plink.exe was not found.
exit /b 1
)
if not exist “%~dp0paloalto-commands.txt” (
echo ERROR: paloalto-commands.txt was not found.
exit /b 1
)
> “%FW_REPORT%” echo Security policy – %DATE% %TIME%
>> “%FW_REPORT%” echo ===== Firewall %FW_IP% =====
echo Collecting Security policy from %FW_IP%…
“%~dp0plink.exe” -ssh -batch -agent -t ^
-l “%FW_USER%” “%FW_IP%” ^
< “%~dp0paloalto-commands.txt” >> “%FW_REPORT%” 2>&1
if errorlevel 1 (
echo ERROR: SSH collection failed. Review “%FW_REPORT%”.
exit /b 1
)
echo Collection finished. Review “%FW_REPORT%”.
endlocal
Here, -t requests a remote terminal and the < operator supplies the commands from the text file. Because we are capturing a terminal session, the report may also contain login banners, echoed commands, prompts and terminal control characters.
Run collect-paloalto.bat from C:NetworkCollection. The following console output is illustrative:
C:NetworkCollection>collect-paloalto.bat
Collecting Security policy from 192.168.0.101…
Collection finished. Review “C:NetworkCollectionpaloalto-security-rules.txt”.
Review the collected firewall rules
The following illustrative excerpt shows the report heading and selected fields from one rule. Login messages, prompts, other fields and the remaining rules are omitted here. The exact layout varies with PAN-OS.
Security policy – 20/11/2026 20:00:00.00
===== Firewall 192.168.0.101 =====
“Allow-Monitoring-Ping; index: 1” {
from MGMT;
source 192.168.0.200;
to SERVERS;
destination 192.168.0.110;
application/service ping/icmp/any/any;
action allow;
}
This example shows a rule allowing the ping application from a monitoring host in the MGMT zone to a server in the SERVERS zone. The application/service field represents the application, protocol, source port and destination port. [10]
Before relying on the collection, test the command file on your PAN-OS release and confirm the report contains the complete policy output, with no paging prompt or CLI errors. This simple batch script sends input without waiting for each device prompt. If a device needs prompt synchronisation, use a client that can wait for prompts or the PAN-OS API.
For a firewall with multiple virtual systems, select the required context using set system setting target-vsys vsys1 before show running security-policy. Replace vsys1 with the required virtual system and collect each authorised scope separately. A single collection should not be assumed to cover every virtual system. [8]
If the requirement also includes NAT rules, collect show running nat-policy separately and identify that output accordingly. The Security policy command does not include NAT rules. [11]
Collect VIPs from a NetScaler load balancer
We can use the same approach with a NetScaler load balancer. In this example, its management IP address is 192.168.0.102. We want to collect the configured IPv4 VIP addresses and see which load balancing and content switching virtual servers use them.
A VIP is the virtual IP address presented for an application or service. The management address is where we connect to administer NetScaler. These serve different purposes. Also, several virtual servers can share a VIP while listening on different ports, so counting virtual servers does not necessarily give us the number of unique VIP addresses.
Start with show ns ip -type VIP to collect the configured IPv4 addresses of type VIP. Then run show lb vserver and show cs vserver without a virtual server name to collect the load balancing and content switching entries visible in the current administrative context. [12] [13] [14]
Collecting both views helps us distinguish the IP inventory from the virtual servers using it. We include DOWN and disabled entries where returned; we are collecting what is configured, rather than filtering the report to services that are currently UP.
Create the NetScaler command file
Save the following as netscaler-commands.txt in C:NetworkCollection:
set cli mode -page OFF -color OFF
show ns ip -type VIP
show lb vserver
show cs vserver
exit
The first command disables pagination and coloured output. The show commands collect the inventory without changing the virtual server configuration. Run them in the NetScaler CLI, not the underlying appliance shell. [15]
Use the same verified host key and Pageant authentication approach as before. The netops account needs permission to run the listed commands and visibility of the required objects.
Create the NetScaler collection script
Save the following as collect-netscaler.bat alongside Plink and the command file:
@echo off
setlocal
set “ADC_IP=192.168.0.102”
set “ADC_USER=netops”
set “ADC_REPORT=%~dp0netscaler-vips.txt”
if not exist “%~dp0plink.exe” (
echo ERROR: plink.exe was not found.
exit /b 1
)
if not exist “%~dp0netscaler-commands.txt” (
echo ERROR: netscaler-commands.txt was not found.
exit /b 1
)
> “%ADC_REPORT%” echo VIP collection – %DATE% %TIME%
>> “%ADC_REPORT%” echo ===== NetScaler %ADC_IP% =====
echo Collecting VIPs from %ADC_IP%…
“%~dp0plink.exe” -ssh -batch -agent -t ^
-l “%ADC_USER%” “%ADC_IP%” ^
< “%~dp0netscaler-commands.txt” >> “%ADC_REPORT%” 2>&1
if errorlevel 1 (
echo ERROR: SSH collection failed. Review “%ADC_REPORT%”.
exit /b 1
)
echo Collection finished. Review “%ADC_REPORT%”.
endlocal
Run collect-netscaler.bat from C:NetworkCollection. The following console output is illustrative:
C:NetworkCollection>collect-netscaler.bat
Collecting VIPs from 192.168.0.102…
Collection finished. Review “C:NetworkCollectionnetscaler-vips.txt”.
Review the collected VIPs
The following illustrative report excerpt shows three IPv4 VIPs and selected virtual server fields. Banners, other fields and additional entries are omitted. The exact format depends on the NetScaler release and CLI settings.
VIP collection – 20/11/2026 20:00:00.00
===== NetScaler 192.168.0.102 =====
> show ns ip -type VIP
Ipaddress Type Mode Arp Icmp Vserver State
1) 192.168.0.201 VIP Active Enabled Enabled Enabled Enabled
2) 192.168.0.202 VIP Active Enabled Enabled Enabled Enabled
3) 192.168.0.203 VIP Active Enabled Enabled Enabled Enabled
Done
> show lb vserver
1) LB-WEB-HTTPS (192.168.0.201:443) – SSL Type: ADDRESS
State: UP
Effective State: UP
2) LB-API-HTTPS (192.168.0.202:443) – SSL Type: ADDRESS
State: DOWN
Effective State: DOWN
Done
> show cs vserver
1) CS-PORTAL-HTTPS (192.168.0.203:443) – SSL Type: CONTENT
State: UP
Done
Here, 192.168.0.201 belongs to a load balancing virtual server that is UP. The virtual server on 192.168.0.202 is DOWN, but it is still part of the inventory. The content switching virtual server uses 192.168.0.203.
The Enabled value in the IP inventory is not proof that the application is available. Check the virtual server state and its supporting services when assessing availability. Also, a non-addressable virtual server may show 0.0.0.0:0; do not count that placeholder as a client-facing VIP.
Confirm the collection scope
This command file collects IPv4 VIPs and load balancing and content switching details in the current administrative context. If IPv6 is in scope, add show ns ip6 before exit and identify the entries of type VIP in that output. It lists IPv6 addresses of other types too. [16]
For deployments using administrative partitions, collect each required partition with an account authorised to see it. These commands should not be treated as an inventory of every partition, every appliance or every virtual server feature. Gateway and authentication virtual server details, for example, need their own feature commands if those details are required.
As with the firewall example, test the command file on the target release and check for complete output and CLI errors. The batch script sends commands without waiting for each prompt. For repeated or larger inventories requiring reliable prompt handling or structured records, a client with prompt synchronisation or the NetScaler NITRO API is a practical next step.
Know the limits of the approach
This gives us a simple way to collect raw CLI output. It does not parse the collected data or decide whether an interface, policy or application is correct. Those would be additional requirements.
Also, -batch disables prompts; it does not provide an overall execution timeout. A stalled connection can delay the remaining switches because this script runs sequentially. For unattended use, we would need a way to enforce a maximum execution time for each connection.
If we extend this to other vendors or operating systems, we also need to account for their command syntax, pagination and SSH command execution behaviour. We should validate those differences on one device before adding them to a wider collection.
My view as an architect
For me, the useful part of this example is how we approach the requirement. We understand the information we need, look at what is available and build a workflow that we can explain and check.
Here, Windows batch handles the repetition, Plink provides SSH connectivity and text files hold the results. We have used that approach to collect interface data from 20 switches, Security policy rules from a Palo Alto firewall and VIP information from a NetScaler load balancer.
Tools will continue to change. Being able to understand the problem and put a workable solution together remains an important skill for an architect.
References
[1] PuTTY documentation — Using the command line connection tool Plink
https://the.earth.li/~sgtatham/putty/latest/htmldoc/Chapter7.html
[2] Official PuTTY download page
https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html
[3] Cisco Nexus 7000 Series NX-OS Fundamentals Configuration Guide — Scripting with Tcl and command separation
[4] Microsoft Learn — for command
https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/for
[5] PuTTY documentation — Using Pageant for authentication
https://the.earth.li/~sgtatham/putty/latest/htmldoc/Chapter9.html
[6] Palo Alto Networks — CLI commands to view Panorama pushed configurations from the managed device
https://knowledgebase.paloaltonetworks.com/KCSArticleDetail?id=kA10g000000CmAYCA0
[7] Palo Alto Networks — How to disable the paging function on CLI
https://knowledgebase.paloaltonetworks.com/KCSArticleDetail?id=kA10g000000Cm1fCAC
[8] Palo Alto Networks — Configure virtual systems
https://docs.paloaltonetworks.com/ngfw/administration/virtual-systems/configure-virtual-systems
[9] Palo Alto Networks — Python script for collecting CLI command outputs periodically
https://knowledgebase.paloaltonetworks.com/KCSArticleDetail?id=kA1Ki000000TO2EKAW
[10] Palo Alto Networks — How Application Default in the rulebase changes the way traffic is matched
https://knowledgebase.paloaltonetworks.com/KCSArticleDetail?id=kA10g000000ClV1CAK
[11] Palo Alto Networks — PAN-OS 11.1 CLI operational command hierarchy
[12] NetScaler command reference — IPv4 address inventory and type filter
https://developer-docs.netscaler.com/us/en/adc-command-reference-int/13-1/ns-ip.html
[13] NetScaler command reference — Load balancing virtual servers
https://developer-docs.netscaler.com/us/en/adc-command-reference-int/13-1/lb-vserver.html
[14] NetScaler command reference — Content switching virtual servers
https://developer-docs.netscaler.com/us/en/adc-command-reference-int/13-1/cs-vserver.html
[15] NetScaler command reference — CLI display mode
https://developer-docs.netscaler.com/us/en/adc-command-reference-int/13-1/cli-mode.html
[16] NetScaler command reference — IPv6 address inventory
https://developer-docs.netscaler.com/us/en/adc-command-reference-int/13-1/ns-ip6.html




Leave a Reply