- Access exclusive content
- Connect with peers
- Share your expertise
- Find support resources
01-01-2017 02:32 AM
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 () {
Param(
[string]$IP,
[string]$HOSTNAME,
[string]$KEY
)
$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 "1.1.1.1" "Boston" "<API KEY>"
getConfiguration "2.2.2.2" "Florida" "<API KEY>"
<#
Generate the API Key Using
https://<PA IP>/esp/restapi.esp?type=keygen&user=<username case sensetive>&password=<url encoded password>
#<
12-15-2017 01:52 AM
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:
/api/?type=export&category=device-state&key=...
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!