Backup Using Powershell

Showing results for 
Show  only  | Search instead for 
Did you mean: 
Please sign in to see details of an important advisory in our Customer Advisories area.

Backup Using Powershell

L4 Transporter

add-type @"
using System.Net;
using System.Security.Cryptography.X509Certificates;
public class TrustAllCertsPolicy : ICertificatePolicy {
public bool CheckValidationResult(
ServicePoint srvPoint, X509Certificate certificate,
WebRequest request, int certificateProblem) {
return true;
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy

$ErrorActionPreference = "SilentlyContinue"
$BACKUP_DIR = "d:\work\temp\"

function getConfiguration () {


$URL = "https://" + $IP + "/esp/restapi.esp?type=export&category=configuration&from=running-config.xml&key=" + $KEY
$TIMESTAMP = Get-Date -format dd-MM-yyyy
$PATH = $BACKUP_DIR + $TIMESTAMP + "_" + $HOSTNAME + "_" + $IP + ".xml"
Invoke-WebRequest -Uri $URL -OutFile $PATH


getConfiguration "" "Boston" "<API KEY>"
getConfiguration "" "Florida" "<API KEY>"

Generate the API Key Using
https://<PA IP>/esp/restapi.esp?type=keygen&user=<username case sensetive>&password=<url encoded password>


L1 Bithead

Awesome - I've also scripted this by myself yesterday - more or less the same code 🙂


One addition: if you work with Panorama you should export the device state on the local boxes. If you only export the running-config it will only include the locally configured settings and not the settings pushed by Panorama. Just use following API query:



  • 1 replies
Like what you see?

Show your appreciation!

Click Like if a post is helpful to you or if you just want to show your support.

Click Accept as Solution to acknowledge that the answer to your question has been provided.

The button appears next to the replies on topics you’ve started. The member who gave the solution and all future visitors to this topic will appreciate it!

These simple actions take just seconds of your time, but go a long way in showing appreciation for community members and the LIVEcommunity as a whole!

The LIVEcommunity thanks you for your participation!