Change Tracking - Log Management via Scripts

Change Tracking - Log Management via Scripts

  • Comments 1
  • Likes

As we've seen, the Change Tracking log is stored alongside the ISA configuration, as an XML file saved in a VPS (Vendor Parameter Set) parameter. Therefore, you can manage it using simple COM scripts.

For example, here's how you save (backup) the logs into XML files:

Const fpcIsaStandardEdition = &H10&
Const fpcIsaEnterpriseEdition = &H20&

If Wscript.Arguments.Count=0 Then
    Wscript.Echo "Usage:   SaveChangeTrackingLogs.vbs" & vbcrlf & _
                 "Example: SaveChangeTrackingLogs.vbs C:\logs\" & vbcrlf & _
                 "- will create the following files:" & vbcrlf & _
                 "    c:\logs\enterprisename.xml" & vbcrlf & _
                 "    c:\logs\arrayname1.xml" & vbcrlf & _
                 "    c:\logs\arrayname2.xml" & vbcrlf & _
                 "    c:\logs\enterprisepolicyname1.xml"
    Wscript.Quit 1
End If

Set fpc = CreateObject("FPC.Root")
If fpc.IsaEdition = fpcIsaStandardEdition Then
    ExportLog fpc.GetContainingArray
Else
    ExportLog fpc.Enterprise
    For Each arr In fpc.Arrays
        ExportLog arr
    Next
    For Each policy In fpc.Enterprise.Policies
        ExportLog policy
    Next
End If

Wscript.Quit 0


Sub ExportLog(CTContainer)
    On Error Resume Next
    Set VendorSet = CTContainer.VendorParametersSets.Item( "{1234C1BD-2502-4BDA-8EAD-B2DE4DD84A7D}" )
    If Err.Number <> 0 Then
        Wscript.Echo "No change tracking log in " + CTContainer.name
        Exit Sub
    End If
    On Error Goto 0

    filename = Wscript.Arguments(0) + CTContainer.name + ".xml"
    Wscript.Echo "Saving change tracking log from " + CTContainer.name + " to " + filename

    Set fso = CreateObject("Scripting.FileSystemObject")
    Set file = fso.CreateTextFile(wscript.arguments(0) + CTContainer.name + ".xml", True, True)
    file.Write VendorSet("changes")
    file.Close
End Sub

[TMG update] In TMG, change ExportLog function to:

Sub ExportLog(CTContainer)
    filename = Wscript.Arguments(0) + CTContainer.name + ".xml"
    Wscript.Echo "Saving change tracking log from " + CTContainer.name + " to " + filename
    CTContainer.ChangeTracking.WriteLogToFile filename
End Sub

And here's how you clear them:

Const fpcIsaStandardEdition = &H10&
Const fpcIsaEnterpriseEdition = &H20&

Set fpc = CreateObject("FPC.Root")
If fpc.IsaEdition = fpcIsaStandardEdition Then
    Set arr = fpc.GetContainingArray
    ClearLog arr
    Wscript.Echo "Saving..."
    arr.Save false, false
Else
    ClearLog fpc.Enterprise
    For Each arr In fpc.Arrays
        ClearLog arr
    Next
    For Each policy In fpc.Enterprise.Policies
        ClearLog policy
    Next
    Wscript.Echo "Saving..."
    fpc.Save false, false
End If

Wscript.Echo "Done"
Wscript.Quit 0


Sub ClearLog(CTContainer)
    On Error Resume Next
    CTContainer.VendorParametersSets.Remove "{1234C1BD-2502-4BDA-8EAD-B2DE4DD84A7D}"
    If Err.Number <> 0 Then
        Wscript.Echo "There was no change tracking log in " + CTContainer.name
        Exit Sub
    End If
    On Error Goto 0

    Wscript.Echo "Cleared change tracking log in " + CTContainer.name
End Sub

[TMG update] In TMG, change ClearLog function to:

Sub ClearLog(CTContainer)
    CTContainer.ChangeTracking.ClearLog = True   'for TMG Beta3, use: CTContainer.ClearLog
    Wscript.Echo "Cleared change tracking log in " + CTContainer.name
End Sub

-Jonathan Barner, ISA Sustained Engineering Team

Comments
  • We've tried to get the Change Tracking viewer to cater to most people's needs. But you may have needs

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment