Microsoft Internet Security and Acceleration Server 2004 SDK |
This VBScript example exports the configuration of an ISA Server computer to a specified .xml file or imports the configuration stored in a specified .xml file to an ISA Server computer. The script includes a single function, called ImportExport.
This example is included as the ImportExport.vbs script in the Sdk\Samples\Admin folder on the ISA Server 2004 CD.
The following procedure lists the steps used to export the configuration of an ISA Server computer to an .xml file and to import the configuration in an .xml file to an ISA Server computer in the code example that follows.
To export and import an ISA Server configuration
The following code can be saved to a .vbs file and run from a command prompt on a computer running ISA Server 2004.
Sub ImportExport() ' Define a constant to indicate that no optional data will ' be exported or imported. const noOptionalData = 0 If WScript.Arguments.Count <> 2 Then WScript.Echo "Error: Invalid number of parameters." & vbCrLf & _ "Syntax:" & vbCrLf & _ "ImportExport {e | i} filename" Exit Sub End If 'Declare the objects needed Dim root ' The FPCLib.FPC root object Dim firewall ' An FPCArray object ' Create the root object. Set root = CreateObject("FPC.Root") ' Get a reference to the array object (firewall). Set firewall = root.GetContainingArray If WScript.Arguments(0) = "e" Then WScript.Echo "Exporting the configuration of the " & firewall.Name & " array object to " & WScript.Arguments(1) & " ..." ' Export the firewall's configuration to the XML document. ' Notice that values are not specified for the optional parameters. firewall.ExportToFile WScript.Arguments(1),noOptionalData WScript.Echo "Exporting was completed successfully." WScript.Quit End If If WScript.Arguments(0) = "i" Then WScript.Echo "Importing the configuration from " & WScript.Arguments(1) & " to the " & firewall.Name & " array object ..." ' Import the firewall's configuration from the XML file specified. ' Notice that values are not specified for some of the optional parameters. firewall.ImportFromFile WScript.Arguments(1),noOptionalData,,,True WScript.Echo "Importing was completed successfully." End If End Sub ImportExport