In the first post of this series, we learned how to automatically deploy switch firmware through PowerShell. Don’t get me wrong, this is awesome! But if you don’t have your switch configuration saved already, you would have to be bloody insane to push a new firmware to the device. No offense to those insane readers who did this. 🙂

So what is an admin to do? Why, use PowerShell to connect to each switch and save the configuration files directly!

I won’t bore you with the setup steps required for this script – read the previous article in this series to generate your switchlist file and to configure your TFTP server. If you’ve already done those steps, this script should run without any issues. Just change the configuration block at the top and edit the switch command line to match your environment. Ensure that your TFTP server has a subfolder named Configs in it.

This script is already configured to backup the configuration for an HP ProCurve Switch. If you have other makes in your environment, leave a comment below with your script alterations.

Startup Configurations will be saved according to the $FilePath and $FileName variables. By default, the script will create a folder under the Configs subfolder for each switch on your TFTP server. The folder will be named after the Switch Host/Node name. This information is pulled from your Switchlist.csv. Each saved configuration is named after the switch’s IP address with a date attached to the end of the file (ex: 10.95.0.1_2016-02-29.txt).

What are you waiting for? Start backing up all of your switch configurations. Schedule this script for automated backups! As with any backup, verify the data. In our next post of this series, we will use PowerShell to change our switch configurations.

In the switch you will also have to enable SSH for the user you log in with(probably “admin”), as well as enable SSH in devices/service menu.

BTW: In part one it is explained how to do the initial setup. but in that guide other column names are used (e.g. IPAddress instead of IP_Address, which is used in the code in part 2). That confuses quite a bit until you find the error.

If I leave out the copy running config code it logs in and goes to priv exec just fine. but if I run the above it interprets it as multiple characters and I can’t get to priv exec. Is there a way to emulate pressing the enter key?