Script para Carregar uma “Rule Set” de uma regra pertencente a um Array de ISA servers.

Ficheiro de dados está em: c:Export.txt, O nome da “Rule Set” é BadsitesVarios. Primeiro o script apaga os dados da “rule set” só depois é que preenche com os novos.

 

Dim limpa
Dim root
Dim urlSets
Dim urlSet
Dim ruleElements
Dim CurArray
Const ForReading = 1
Dim arrFileLines()
Set objFile = objFSO.OpenTextFile ("C:Export.txt", ForReading)
objFSO = CreateObject ("Scripting.FileSystemObject")
set root = CreateObject("FPC.Root")
Set CurArray = root.Enterprise
Set urlSets = CurArray.RuleElements.URLSets
Set urlset = URLSets.item("BadsitesVarios")
i = 0
Do Until objFile.AtEndOfStream
     Redim Preserve arrFileLines(i)
     arrFileLines(i) = objFile.ReadLine
     i = i + 1
Loop
objFile.Close
Limpa = DeleteAllUrlsInUrlSet("<b>BadsitesVarios</b>")
if limpa = false then
     wscript.echo "Não Foi apagado nada"
     wscript.close
end if
For Each strLine in arrFileLines
     on error resume next
     urlset.add strLine
     If Err.Number = 421 Then Err.Clear 'URL Set already exists.
     End if
Next
urlset.save
wscript.echo "Adicionado"
Function DeleteAllUrlsInUrlSet(sUrlSetName)
     Dim oFPC 'Root COM object for ISA admin.
     Dim oIsaArray 'The local ISA Server or ISA Array.
     Dim cUrlSets 'FPCURLSets collection.
     Dim cUrlSet 'FPCURLSet collection.
     Dim sUrl
     Set oFPC = CreateObject("FPC.Root")
     Set oIsaArray = oFPC.Enterprise
     Set cUrlSets = oIsaArray.RuleElements.URLSets
     Set cUrlSet = cUrlSets.Item(sUrlSetName)
     For Each sUrl In cUrlSet
          cUrlSet.Remove(sUrl)
     Next
     cUrlSet.Save
     If Err.Number = 0 Then DeleteAllUrlsInUrlSet = True
     Else DeleteAllUrlsInUrlSet = False
End Function

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.