Add port forwarding support, improve XML documentation, and add unit tests

This commit is contained in:
GraceSolutions
2025-04-14 22:48:53 -04:00
commit afcb6dbbfa
203 changed files with 30165 additions and 0 deletions
@@ -0,0 +1,29 @@
# Import the module
Import-Module PSOPNSenseAPI
# Connect to the OPNSense firewall
Connect-OPNSense -Server "https://firewall.example.com" -ApiKey "your_api_key" -ApiSecret "your_api_secret" -SkipCertificateCheck
# Get all configuration backups
$backups = Get-OPNSenseConfigBackup
$backups | Format-Table -Property Filename, Description, FileSize, Date, Version
# Create a new configuration backup
$backupFilename = Backup-OPNSenseConfig -Filename "pre-upgrade-backup"
Write-Output "Created backup: $backupFilename"
# Export the configuration to a file
$exportPath = "C:\Backups\opnsense-config.xml"
Export-OPNSenseConfig -Path $exportPath -Force
Write-Output "Exported configuration to: $exportPath"
# Import a configuration from a file
# Note: This will restart the firewall
# Import-OPNSenseConfig -Path $exportPath -Confirm
# Restore a configuration backup
# Note: This will restart the firewall
# Restore-OPNSenseConfig -Filename $backupFilename -Confirm
# Disconnect from the firewall
Disconnect-OPNSense