This script sets the password for a given username on all Cisco devices. The user will be prompted for a valid username and password when the script is executed. If an account does not already exist for the given username, one will be created.
Script:
Example 1 - Cisco Set User Password
Script-Description:
This script sets the password for a given username on all Cisco
devices. The user will be prompted for a valid username and
password when the script is executed. If an account does not
already exist for the given username, one will be created.
This example demonstrates the use of a simple action that is
executed once on every appropriate device.
#-----------------------------------------------------------------------
# The Script-Filter is used to indicate that the entire script
# should only be executed for Cisco IOS devices.
#-----------------------------------------------------------------------
Script-Filter:
$Vendor eq "Cisco" and $sysDescr like /IOS/
#-----------------------------------------------------------------------
# Script-Variables are defined to allow the user to provide input
# to the script. In this example, the user will be prompted to
# enter a username and password prior to script execution. The
# username is defined as type "word", which means any string
# without whitespace can be entered. The password is defined as
# type "password", which means any string can be entered, however
# only stars will be displayed.
#
# The "UserName" and "Password" fields define the GUI prompts
# to be displayed to the user when the script is executed.
#-----------------------------------------------------------------------
Script-Variables:
$username word "UserName"
$password password "New Password"
########################################################################
Action:
Set IOS User Password
Action-Description:
This action is executed once for every device that matches the
Script-Filter defined above. It sets the password for the
given user account and then saves the configuration.
Action-Commands:
config terminal
username $username password 0 $password
exit
write memory
########################################################################

Add comment