The ISA servers I maintain are hosted at a third party datacenter, which charges a premium for backups. Since the only thing I want to backup from the ISA servers is the ISA configuration, I have just been exporting to an xml and copying it off on occasion. Of course, a manual process is a bad thing, so I started looking around for a way to automate this. Google helped me find a couple of good posts, which I combined to produce the script below.
‘ VB Script Document
””””””””””””””””””””””””””””””””””””””””
‘ This script is based heavily on a posting at isaserver.org
‘ http://forums.isaserver.org/Automate_Backup_to_XML%3f%3f/m_2002017454/tm.htm
‘ created by Andy_UK. It also draws from another posting by Paul Sadowski at
‘ http://www.paulsadowski.com/WSH/cdo.htm#LoadFromFile
‘ I cleaned it up just a bit, debugged a couple of minor things that probably
‘ were necessitated by my own typoes and NOT the source content, and added the
‘ functionality to attach the file to the email notification.
‘ This script exports the configuration of the array object of an ISA Server
‘ computer to a specified XML file or imports the configuration in a specified
‘ XML file to array object of the ISA Server computer.
‘ The following parameter must be included on the command line:
‘ – The letter "e" to export
‘ – or "i" to indicate import
‘ When e is selected, script will export to file and location specified and then
‘ email the file to the specified address.
‘ When i is selected, a prompt box will appar asking for full path and filename
‘ to import, a message will be displayed when selection has been made and when
‘ import is complete.
‘ Note, you must use this script to import any configuration file that you
‘ created by using this script to export. I don’t know why, but that is what
‘ several different posters have mentioned in the isaserver.org forums.
‘ Use at your own risk, test thoroughly in your dev environment before putting
‘ this into production. Please share this freely if you find it useful.
””””””””””””””””””””””””””””””””””””””””
option explicit
Sub ImportExport()
‘ Define a constant to indicate that no optional data will
‘ be exported or imported.
const noOptionalData = 0
‘Declare the objects needed
Dim root ‘ The FPCLib.FPC root object
Dim firewall ‘ An FPCArray object
Dim strComputer
Dim objMessage
‘ Create the root obect.
Set root = CreateObject("FPC.Root")
‘ Get a reference to the array object (firewall).
Set firewall = root.GetContainingArray
If WScript.Arguments(0) = "e" Then
‘ Export the configuration to the XML file.
‘ Notice that values are not specified for the optional parameters.
firewall.ExportToFile "C:\backups\"& replace(Date,"/","_")+"_ISA_CONFIG.XML", noOptionalData
Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "IsaServerName backup run"
objMessage.From = "IsaServerName@example.com"
objMessage.To = "admin@example.com"
objMessage.AddAttachment "C:\backups\"& replace(Date,"/","_")+"_ISA_CONFIG.XML"
objMessage.TextBody = " the daily backup completed "
‘==This section provides the configuration information for the remote SMTP server.
‘==Normally you will only change the server name or IP.
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
‘Name or IP of Remote SMTP Server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.example.com"
‘Server port (typically 25)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objMessage.Configuration.Fields.Update
‘==End remote SMTP server configuration section==
objMessage.Send
WScript.Quit
End If
If WScript.Arguments(0) = "i" Then
Do
strfileloc = (InputBox(" Location and Filename to Import", "File to Import"))
If strfileloc <> "" Then
strInput = True
End if
Loop until strInput = True
WScript.Echo "Importing the configuration from " & strfileloc & " to the " & firewall.Name & " array object, a message will appear when complete"
‘ Import the firewall’s configuration from the XML file specified.
‘ Notice that values are not specified for some of the optional parameters.
firewall.ImportFromFile strfileloc,noOptionalData,,,True
WScript.Echo "Importing was completed successfully."
End If
End Sub
ImportExport
Set this as a scheduled task and you are all done!
keywords: ISA 2006, backups, script, email
I hope you find this useful, and if you do, please comment. If you find anything above that needs to be changed, or if your environment needed additional tweaking, please also comment so I can either revise the information above, or so that others with similar situations can see what you did differently. Thanks!
You might also enjoy:





