Advertisement
Guest User

Microsoft Forefront TMG 2010 Backup ImportExport.vbs modded

a guest
Apr 5th, 2013
544
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 2.84 KB | None | 0 0
  1. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  2. ' Copyright (c) Microsoft Corporation. All rights reserved.
  3. ' THIS CODE IS MADE AVAILABLE AS IS, WITHOUT WARRANTY OF ANY KIND. THE ENTIRE
  4. ' RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS CODE REMAINS WITH THE
  5. ' USER. USE AND REDISTRIBUTION OF THIS CODE, WITH OR WITHOUT MODIFICATION, IS
  6. ' HEREBY PERMITTED.
  7. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  8.  
  9. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  10. ' This script exports the configuration of the array object of an TMG Server
  11. ' computer to a specified XML file or imports the configuration in a specified
  12. ' XML file to array object of the TMG Server computer.
  13. ' The following two parameters must be included on the command line:
  14. '    1. The letter "e" or "i" to indicate whether the configuration will be
  15. '       exported or imported.
  16. '    2. The name of the XML file.
  17. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  18.  
  19. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  20. ' 2013-04-05  this is based on ImportExport.vbs in the TMG 2010 SDK (TMGSDK.exe)
  21. '             check the samples/Admin/ImportExport.cvs for the original
  22. '             I've removed the import function, made it only ask for a directory
  23. '             -nf
  24. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  25.  
  26. Sub ExportTMGConfiguration()
  27.  
  28.     ' Define a constant to indicate that no optional data will
  29.     ' be exported or imported.
  30.     const noOptionalData = 0
  31.  
  32.     If WScript.Arguments.Count <> 1 Then
  33.         WScript.Echo "Error: Invalid number of parameters." & vbCrLf & _
  34.                      "Syntax:" & vbCrLf & _
  35.                      "ImportExport path-for-backups"
  36.         Exit Sub
  37.     End If
  38.  
  39.     'Declare the objects needed
  40.     Dim root      ' The FPCLib.FPC root object
  41.     Dim firewall  ' An FPCArray object
  42.     Dim backup_filename ' file that we're backing up to...
  43.  
  44.     ' Create the root obect.
  45.     Set root = CreateObject("FPC.Root")
  46.  
  47.     ' Get a reference to the array object (firewall).
  48.     Set firewall = root.GetContainingArray
  49.  
  50.     ' Set the backup filename
  51.     backup_filename = WScript.Arguments(0) & "\" & firewall.Name & "_" & Year(Now) & "-" & Month(Now) & "-" & Day(Now) & "_" & Hour(Now) & "." & Minute(Now) & "." & Second(Now) & ".xml"
  52.  
  53.     WScript.Echo "Exporting the configuration of the " & firewall.Name & " array object to " & backup_filename & " ..."
  54.  
  55.     ' Export the configuration to the XML file.
  56.     ' Notice that values are not specified for the optional parameters.
  57.     firewall.ExportToFile backup_filename, noOptionalData
  58.     WScript.Echo "Exporting was completed successfully."
  59.     WScript.Quit
  60.  
  61. End Sub
  62.  
  63. ExportTMGConfiguration
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement