This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Importing Exclusions into a policy

Is it possible to import exclusions into a policy. Now it's a big typing and copy past session to update several policies with new exclusions when necessary.

Thanks, Ernst

:19085


This thread was automatically locked due to age.
Parents
  • strServerName       = ".\SEC5"   '<----Enter DB server name and instance here
    strDatabaseName     = "Sophos50" '<----Enter DB name here  (e.g. SOPHOS45, SOPHOS47,...)
    strConnectionString = "Driver={SQL Server};Server="&strServerName&";Database="&strDatabaseName&";Trusted_Connection=yes;"
    
    strSQL = "SELECT p.name, p.policyxml.query('" &_
         "declare namespace SAV=""http://www.sophos.com/EE/EESavConfiguration""; " &_
         "(/SAV:config/SAV:onAccessScan/SAV:exclusions/SAV:filePathSet/SAV:filePath) " &_
         " ') as Exclusion " &_
         "FROM policies as p with (nolock) where p.type = 2" 
    
    	 wscript.echo strSQL
    	 
    set cn = CreateObject("ADODB.Connection")
    cn.open strConnectionString
    
    Set rs = CreateObject("ADODB.Recordset")
    rs.Open strSQL, cn
    
    ' Write file to disk
    set fso = CreateObject("Scripting.FileSystemObject")
    
    ' Loop for each record
    Do Until rs.EOF
    	strEx = rs("Exclusion") 
       if strEx <> "" then
         CreateFile rs("Name"), strEx
       end if
      rs.movenext
    Loop
    
    'cleanup
    set cn  = nothing
    set rs  = nothing
    set fso = nothing
    
    'Functions-------------------------------------------------------------------------------------------
    Function  CreateFile (strName, strXML)
      on error resume next
    
      set file = fso.OpenTextFile(strName & "-Exclusions.txt", 2, True)
      arr1 = split (strXML, "<SAV:filePath xmlns:SAV=""http://www.sophos.com/EE/EESavConfiguration"">")
      for a = 0 to ubound (arr1)
        if arr1(a) <> "" then
          file.writeline replace(arr1(a), "</SAV:filePath>", "")
        end if
      next
    
      file.close
      set file = nothing
    End function
    '-----------------------------------------------------------------------------------------------------
    
    :19101
Reply
  • strServerName       = ".\SEC5"   '<----Enter DB server name and instance here
    strDatabaseName     = "Sophos50" '<----Enter DB name here  (e.g. SOPHOS45, SOPHOS47,...)
    strConnectionString = "Driver={SQL Server};Server="&strServerName&";Database="&strDatabaseName&";Trusted_Connection=yes;"
    
    strSQL = "SELECT p.name, p.policyxml.query('" &_
         "declare namespace SAV=""http://www.sophos.com/EE/EESavConfiguration""; " &_
         "(/SAV:config/SAV:onAccessScan/SAV:exclusions/SAV:filePathSet/SAV:filePath) " &_
         " ') as Exclusion " &_
         "FROM policies as p with (nolock) where p.type = 2" 
    
    	 wscript.echo strSQL
    	 
    set cn = CreateObject("ADODB.Connection")
    cn.open strConnectionString
    
    Set rs = CreateObject("ADODB.Recordset")
    rs.Open strSQL, cn
    
    ' Write file to disk
    set fso = CreateObject("Scripting.FileSystemObject")
    
    ' Loop for each record
    Do Until rs.EOF
    	strEx = rs("Exclusion") 
       if strEx <> "" then
         CreateFile rs("Name"), strEx
       end if
      rs.movenext
    Loop
    
    'cleanup
    set cn  = nothing
    set rs  = nothing
    set fso = nothing
    
    'Functions-------------------------------------------------------------------------------------------
    Function  CreateFile (strName, strXML)
      on error resume next
    
      set file = fso.OpenTextFile(strName & "-Exclusions.txt", 2, True)
      arr1 = split (strXML, "<SAV:filePath xmlns:SAV=""http://www.sophos.com/EE/EESavConfiguration"">")
      for a = 0 to ubound (arr1)
        if arr1(a) <> "" then
          file.writeline replace(arr1(a), "</SAV:filePath>", "")
        end if
      next
    
      file.close
      set file = nothing
    End function
    '-----------------------------------------------------------------------------------------------------
    
    :19101
Children
No Data