Backup Using Powershell

L4 Transporter

Backup Using Powershell

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:



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 Live Community as a whole!

The Live Community thanks you for your participation!