Files
PSOPNSenseAPI/docs/cmdlets/Restore-OPNSenseConfig.md
T
GraceSolutions 68e6819131 Update configuration management cmdlets
- Added Get-OPNSenseConfig cmdlet that retrieves the OPNSense configuration as an XML document
- Updated Restore-OPNSenseConfig to accept an XML document from the pipeline or as a parameter
- Changed Export-OPNSenseConfig and Import-OPNSenseConfig to use System.IO.FileInfo for the Path parameter
- Removed Backup-OPNSenseConfig cmdlet (use Get-OPNSenseConfig instead)
- Updated documentation and examples
2025-04-15 08:53:09 -04:00

3.1 KiB

Restore-OPNSenseConfig

SYNOPSIS

Restores an OPNSense firewall configuration.

SYNTAX

Filename

Restore-OPNSenseConfig -Filename <String> [-Force] [-WhatIf] [-Confirm]

XmlDocument

Restore-OPNSenseConfig -XmlDocument <XmlDocument> [-Force] [-WhatIf] [-Confirm]

DESCRIPTION

The Restore-OPNSenseConfig cmdlet restores an OPNSense firewall configuration from a backup or an XML document.

EXAMPLES

Example 1: Restore a configuration backup

Restore-OPNSenseConfig -Filename "config-backup-20250414-1234.xml"

This example restores an OPNSense firewall configuration from a backup file.

Example 2: Restore a configuration from an XML document

$config = Get-OPNSenseConfig
Restore-OPNSenseConfig -XmlDocument $config

This example restores an OPNSense firewall configuration from an XML document.

Example 3: Restore a configuration from the pipeline

Get-OPNSenseConfig | Restore-OPNSenseConfig

This example restores an OPNSense firewall configuration from the pipeline.

PARAMETERS

-Filename

The filename of the backup to restore.

Type: String
Parameter Sets: Filename
Aliases:

Required: True
Position: 0
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-XmlDocument

The XML document containing the configuration to restore.

Type: XmlDocument
Parameter Sets: XmlDocument
Aliases:

Required: True
Position: 0
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False

-Force

Suppresses the confirmation prompt.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Type: SwitchParameter
Parameter Sets: (All)
Aliases: wi

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Confirm

Prompts you for confirmation before running the cmdlet.

Type: SwitchParameter
Parameter Sets: (All)
Aliases: cf

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

System.Xml.XmlDocument

An XML document containing the OPNSense configuration.

OUTPUTS

None

NOTES

This cmdlet requires a connection to an OPNSense firewall. Use Connect-OPNSense to establish a connection. The firewall will restart after the configuration is restored.

Get-OPNSenseConfig Export-OPNSenseConfig Import-OPNSenseConfig