Pré-requisitos:

  • Instalar o 7-zip

Estrutura de Diretórios:

  • C:\Suporte\Backup\Armazenamento\Sites
  • C:\Suporte\Backup\Armazenamento\Farm
  • C:\Suporte\Backup\Scripts

No diretorio de Scripts deverão ter 2 arquivos

  1. BKPSPFarm&Site.ps1
    • Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue
      Backup-SPFarm -Directory C:\Suporte\Backup\Armazenamento\Farm -BackupMethod Full
      Backup-SPSite -Identity http://sharepoint.eficienti.local -Path C:\Suporte\Backup\Armazenamento\Sites\Sharepoint.eficienti.local.bak –Force
       
  2. Compacta_Sharepoint_Backup.bat
    • @echo off
      :As variaveis de data podem ser diferentes dependendo do Idioma do windows
      set ANO=%date:~10,4%
      set MES=%date:~4,2%
      set DIA=%date:~7,2%
      set DATA=%ANO%-%MES%-%DIA%

      set BKPDESTINO=\\DFS\backup\Sharepoint2010_%DATA%.7z
      set BKPORIGEM=C:\Suporte\Backup\Armazenamento
      set LOG=\\DFS\backup\Sharepoint2010_%DATA%.log

      cd C:\Program Files\7-Zip

      :Delete_Historico
      ::Delete de Bkps e Logs no historico com mais de 30 dias
      forfiles /P %BKPDESTINO% /M *.7z /S /D -30 /c “cmd /c del @file”
      forfiles /P %LOG%\.. /M *.log /S /D -30 /c “cmd /c del @file”

      :Inicio
      7z a -mx9 %BKPDESTINO% %BKPORIGEM% > %LOG%
      if %errorlevel% equ 0 (del /F/S/Q %BKPORIGEM%\*.*)

Criar duas tarefas agendadas no Windows:

  1. ScheduleBackupSharepoint
    • Action:
      • Start a program: PowerShell.exe
      • Arguments: &’C:\Suporte\Backup\Scripts\BKPSPFarm&Site.ps1′
  2. ScheduleBackupCompactacao
    • Action:
      • C:\Suporte\Backup\Scripts\Compacta_Sharepoint_Backup.bat
Anúncios

Todo o procedimento naturalmente será feito via Putty

 

1 – Primeiramente Vamos verificar quais tablespaces estão precisando de um upgrade no seu espaço

1.1 – Ajustar a variavel para o banco que iremos trabalhar, no nosso exemplo dbora1

  • ORACLE_SID=dbora1

1.2 – Acessar o SQLPLUS

  • sqlplus /nolog
  • connect as sysdba
  • sys
  • password

1.3 – Colar todo script abaixo para exibir todas as tablespaces do nosso banco

SELECT /* + RULE */ df.tablespace_name “Tablespace”,
df.bytes / (1024 * 1024) “Size (MB)”,
SUM(fs.bytes) / (1024 * 1024) “Free (MB)”,
Nvl(Round(SUM(fs.bytes) * 100 / df.bytes),1) “% Free”,
Round((df.bytes – SUM(fs.bytes)) * 100 / df.bytes) “% Used”
FROM dba_free_space fs,
(SELECT tablespace_name,SUM(bytes) bytes
FROM dba_data_files
GROUP BY tablespace_name) df
WHERE fs.tablespace_name (+) = df.tablespace_name
GROUP BY df.tablespace_name,df.bytes
UNION ALL
SELECT /* + RULE */ df.tablespace_name tspace,
fs.bytes / (1024 * 1024),
SUM(df.bytes_free) / (1024 * 1024),
Nvl(Round((SUM(fs.bytes) – df.bytes_used) * 100 / fs.bytes), 1),
Round((SUM(fs.bytes) – df.bytes_free) * 100 / fs.bytes)
FROM dba_temp_files fs,
(SELECT tablespace_name,bytes_free,bytes_used
FROM v$temp_space_header
GROUP BY tablespace_name,bytes_free,bytes_used) df
WHERE fs.tablespace_name (+) = df.tablespace_name
GROUP BY df.tablespace_name,fs.bytes,df.bytes_free,df.bytes_used
ORDER BY 4 DESC;

 

vamos suporte que nossa tablespace tbls_1 esteja apenas com 1% livre

 

2 – Agora Vamos aumentar nossa tablespace para 750 Mega;

2.1 – Sair do sqlplus

2.2 – Ainda pelo putty vamos localizar o caminho fisico da nossa tablespace:

  • locate tbls_1.dbf

2.3 – Novamente entrar no sqlplus a exemplo do passo 1.2

2.4 – Finalmente aumentando nossa tablespace

  • alter database datafile ‘/home/u01/app/oracle/oradata/databasename/tbls_1.dbf’ resize 750m;

 

obs: usei m pq estou definindo o tamanho em mega, mas poderia usar g para giga 😉

Precisei efetuar a alteração, e utilizei essa base.

Fiquem atento a necessidade recriação do usuário utilizado pelo sistema.

É comum termos a necessidade de utilizarmos um aplicativo para compactação de bkps ou arquivos na rede ou local de maneira automatizado.

A Solução apresentada abaixo, pode ser pensada inclusive como solução de backup basico em alguns casos.

Vamos abordar a utilização de backups com o 7zip:

Criar a estrutura de Diretorios:

C:\Backup

C:\Backup\Scripts

C:\Backup\Logs

C:\Backup\Compacto

Script para Compactação de arquivos:

 

:Variaveis

set DATA=%date:~6,4%-%date:~3,2%-%date:~0,2%

:obs, opcionalmente Podemos colocar na lista de exceção algum subdiretorio usando o parametro -xr!MeuDiretorio no 7-zip
set Arquivos-Origem=\\eficienti.local\arquivos\Comum

set Arquivos-Temp=C:\Backup\Dados
set Arquivos-Destino=C:\Backup\Compacto\Compacto-%DATA%

set Report-Email=C:\Backup\Scripts\Envio_Email.vbs
set Log7z=C:\Backup\Logs
set Mensagem=Erro na compactacao dos arquivos de Backup
set MensagemCopia=Erro na Copia de um ou mais arquivos de Backup

================================================================
:Copiar arquivos para Maquina Local
del %Arquivos-Temp% /q
xcopy %Arquivos-Origem% %Arquivos-temp% /E/Y/I
if %%errorlevel% neq 0 (Goto erro)

:inicio

::Historico – delete arquivo com mais de 30 dias
forfiles /P %Arquivos-Destino% /S /D -30 /c “cmd /c del @file”
forfiles /P %Log7Z% /M *.log /S /D -30 /c “cmd /c del @file”

:Compact
:Verifique se o caminho do 7zip esta no local correto
“c:\Program Files\7-Zip\7z.exe” a -t7z %Arquivos-Destino% %Arquivos-Temp% > %Log7z%\Incremental_Compacto_%DATA%.log

if %ERRORLEVEL% NEQ 0 (Goto Erro2)

if %ERRORLEVEL% EQU 0 (Goto FIM)

:FIM
exit

:Erro
cscript %Report-Email% “%MensagemCopia%”

Goto Inicio

:Erro2
cscript %Report-Email% %Mensagem%

Goto FIM

O Import de blacklist no ISA Server 2006 pode ser “automatizado” desde que montado com os scripts corretos e com o download de uma blacklist confiavel.

Abaixo o procedimento:
(Pacote montado pode ser solicitado para envio por e-mail)

1 – Criando a bat de importaçao
No ISA Server 2006, Criar em c:\Blacklist um arquivo .bat e edita-lo conforme abaixo (nome sugerido: Execute-Import-In-Isa-2006.bat):

.\ISA_Fill_Domain_Name_Set.vbs ADV .\BL\adv\domains
.\ISA_Fill_URL_Set.vbs ADV .\BL\adv\urls /prependstar

.\ISA_Fill_Domain_Name_Set.vbs aggressive .\BL\aggressive\domains
.\ISA_Fill_URL_Set.vbs aggressive .\BL\aggressive\urls /prependstar

.\ISA_Fill_Domain_Name_Set.vbs alcohol .\BL\alcohol\domains
.\ISA_Fill_URL_Set.vbs alcohol .\BL\alcohol\urls /prependstar

.\ISA_Fill_Domain_Name_Set.vbs anonvpn .\BL\anonvpn\domains
.\ISA_Fill_URL_Set.vbs anonvpn .\BL\anonvpn\urls /prependstar

.\ISA_Fill_Domain_Name_Set.vbs automobile .\BL\automobile\domains
.\ISA_Fill_URL_Set.vbs automobile .\BL\automobile\urls /prependstar

.\ISA_Fill_Domain_Name_Set.vbs chat .\BL\chat\domains
.\ISA_Fill_URL_Set.vbs chat .\BL\chat\urls /prependstar

.\ISA_Fill_Domain_Name_Set.vbs costtraps .\BL\costtraps\domains
.\ISA_Fill_URL_Set.vbs costtraps .\BL\costtraps\urls /prependstar

.\ISA_Fill_Domain_Name_Set.vbs dating .\BL\dating\domains
.\ISA_Fill_URL_Set.vbs dating .\BL\dating\urls /prependstar

.\ISA_Fill_Domain_Name_Set.vbs downloads .\BL\downloads\domains
.\ISA_Fill_URL_Set.vbs downloads .\BL\downloads\urls /prependstar

.\ISA_Fill_Domain_Name_Set.vbs drugs .\BL\drugs\domains
.\ISA_Fill_URL_Set.vbs drugs .\BL\drugs\urls /prependstar

.\ISA_Fill_Domain_Name_Set.vbs dynamic .\BL\dynamic\domainsr
.\ISA_Fill_URL_Set.vbs dynamic .\BL\dynamic\urls /prependstar

.\ISA_Fill_Domain_Name_Set.vbs education .\BL\education\domains
.\ISA_Fill_URL_Set.vbs education .\BL\education\urls /prependstar

.\ISA_Fill_Domain_Name_Set.vbs finance .\BL\finance\domains
.\ISA_Fill_URL_Set.vbs finance .\BL\finance\urls /prependstar

.\ISA_Fill_Domain_Name_Set.vbs fortunetelling .\BL\fortunetelling\domains
.\ISA_Fill_URL_Set.vbs fortunetelling .\BL\fortunetelling\urls /prependstar

.\ISA_Fill_Domain_Name_Set.vbs forum .\BL\forum\domains
.\ISA_Fill_URL_Set.vbs forum .\BL\forum\urls /prependstar

.\ISA_Fill_Domain_Name_Set.vbs gamble .\BL\gamble\domains
.\ISA_Fill_URL_Set.vbs gamble .\BL\gamble\urls /prependstar

.\ISA_Fill_Domain_Name_Set.vbs government .\BL\government\domains
.\ISA_Fill_URL_Set.vbs government .\BL\government\urls /prependstar

.\ISA_Fill_Domain_Name_Set.vbs hacking .\BL\hacking\domains
.\ISA_Fill_URL_Set.vbs hacking .\BL\hacking\urls /prependstar

.\ISA_Fill_Domain_Name_Set.vbs hobby .\BL\hobby\domains
.\ISA_Fill_URL_Set.vbs hobby .\BL\hobby\urls /prependstar

.\ISA_Fill_Domain_Name_Set.vbs homestyle .\BL\homestyle\domains
.\ISA_Fill_URL_Set.vbs homestyle .\BL\homestyle\urls /prependstar

.\ISA_Fill_Domain_Name_Set.vbs hospitals .\BL\hospitals\domains
.\ISA_Fill_URL_Set.vbs hospitals .\BL\hospitals\urls /prependstar

.\ISA_Fill_Domain_Name_Set.vbs imagehosting .\BL\imagehosting\domains
.\ISA_Fill_URL_Set.vbs imagehosting .\BL\imagehosting\urls /prependstar

.\ISA_Fill_Domain_Name_Set.vbs isp .\BL\isp\domains
.\ISA_Fill_URL_Set.vbs isp .\BL\isp\urls /prependstar

.\ISA_Fill_Domain_Name_Set.vbs jobsearch .\BL\jobsearch\domains
.\ISA_Fill_URL_Set.vbs jobsearch .\BL\jobsearch\urls /prependstar

.\ISA_Fill_Domain_Name_Set.vbs library .\BL\library\domains
.\ISA_Fill_URL_Set.vbs library .\BL\library\urls /prependstar

.\ISA_Fill_Domain_Name_Set.vbs military .\BL\military\domains
.\ISA_Fill_URL_Set.vbs military .\BL\military\urls /prependstar

.\ISA_Fill_Domain_Name_Set.vbs models .\BL\models\domains
.\ISA_Fill_URL_Set.vbs models .\BL\models\urls /prependstar

.\ISA_Fill_Domain_Name_Set.vbs movies .\BL\movies\domains
.\ISA_Fill_URL_Set.vbs movies .\BL\movies\urls /prependstar

.\ISA_Fill_Domain_Name_Set.vbs music .\BL\music\domains
.\ISA_Fill_URL_Set.vbs music .\BL\music\urls /prependstar

.\ISA_Fill_Domain_Name_Set.vbs news .\BL\news\domains
.\ISA_Fill_URL_Set.vbs news .\BL\news\urls /prependstar

.\ISA_Fill_Domain_Name_Set.vbs podcasts .\BL\podcasts\domains
.\ISA_Fill_URL_Set.vbs podcasts .\BL\podcasts\urls /prependstar

.\ISA_Fill_Domain_Name_Set.vbs politics .\BL\politics\domains
.\ISA_Fill_URL_Set.vbs politics .\BL\politics\urls /prependstar

.\ISA_Fill_Domain_Name_Set.vbs recreation .\BL\recreation\domains
.\ISA_Fill_URL_Set.vbs recreation .\BL\recreation\urls /prependstar

.\ISA_Fill_Domain_Name_Set.vbs radiotv .\BL\radiotv\domains
.\ISA_Fill_URL_Set.vbs radiotv .\BL\radiotv\urls /prependstar

.\ISA_Fill_Domain_Name_Set.vbs redirector .\BL\redirector\domains
.\ISA_Fill_URL_Set.vbs redirector .\BL\redirector\urls /prependstar

.\ISA_Fill_Domain_Name_Set.vbs religion .\BL\religion\domains
.\ISA_Fill_URL_Set.vbs religion .\BL\religion\urls /prependstar

.\ISA_Fill_Domain_Name_Set.vbs remotecontrol .\BL\remotecontrol\domains
.\ISA_Fill_URL_Set.vbs remotecontrol .\BL\remotecontrol\urls /prependstar

.\ISA_Fill_Domain_Name_Set.vbs ringtones .\BL\ringtones\domains
.\ISA_Fill_URL_Set.vbs ringtones .\BL\ringtones\urls /prependstar

.\ISA_Fill_Domain_Name_Set.vbs science .\BL\science\domains
.\ISA_Fill_URL_Set.vbs science .\BL\science\urls /prependstar

.\ISA_Fill_Domain_Name_Set.vbs searchengines .\BL\searchengines\domains
.\ISA_Fill_URL_Set.vbs searchengines .\BL\searchengines\urls /prependstar

.\ISA_Fill_Domain_Name_Set.vbs sex .\BL\sex\domains
.\ISA_Fill_URL_Set.vbs sex .\BL\sex\urls /prependstar

.\ISA_Fill_Domain_Name_Set.vbs shopping .\BL\shopping\domains
.\ISA_Fill_URL_Set.vbs shopping .\BL\shopping\urls /prependstar

.\ISA_Fill_Domain_Name_Set.vbs socialnet .\BL\socialnet\domains
.\ISA_Fill_URL_Set.vbs socialnet .\BL\socialnet\urls /prependstar

.\ISA_Fill_Domain_Name_Set.vbs spyware .\BL\spyware\domains
.\ISA_Fill_URL_Set.vbs spyware .\BL\spyware\urls /prependstar

.\ISA_Fill_Domain_Name_Set.vbs tracker .\BL\tracker\domains
.\ISA_Fill_URL_Set.vbs tracker .\BL\tracker\urls /prependstar

.\ISA_Fill_Domain_Name_Set.vbs updatesites .\BL\updatesites\domains
.\ISA_Fill_URL_Set.vbs updatesites .\BL\updatesites\urls /prependstar

.\ISA_Fill_Domain_Name_Set.vbs urlshortener .\BL\urlshortener\domains
.\ISA_Fill_URL_Set.vbs urlshortener .\BL\urlshortener\urls /prependstar

.\ISA_Fill_Domain_Name_Set.vbs violence .\BL\violence\domains
.\ISA_Fill_URL_Set.vbs violence .\BL\violence\urls /prependstar

.\ISA_Fill_Domain_Name_Set.vbs warez .\BL\warez\domains
.\ISA_Fill_URL_Set.vbs warez .\BL\warez\urls /prependstar

.\ISA_Fill_Domain_Name_Set.vbs weapons .\BL\weapons\domains
.\ISA_Fill_URL_Set.vbs weapons .\BL\weapons\urls /prependstar

.\ISA_Fill_Domain_Name_Set.vbs webmail .\BL\webmail\domains
.\ISA_Fill_URL_Set.vbs webmail .\BL\webmail\urls /prependstar

.\ISA_Fill_Domain_Name_Set.vbs webphone .\BL\webphone\domains
.\ISA_Fill_URL_Set.vbs webphone .\BL\webphone\urls /prependstar

.\ISA_Fill_Domain_Name_Set.vbs webradio .\BL\webradio\domains
.\ISA_Fill_URL_Set.vbs webradio .\BL\webradio\urls /prependstar

.\ISA_Fill_Domain_Name_Set.vbs webtv .\BL\webtv\domains
.\ISA_Fill_URL_Set.vbs webtv .\BL\webtv\urls /prependstar

.\ISA_Fill_Domain_Name_Set.vbs porn .\BL\porn\domains
.\ISA_Fill_URL_Set.vbs porn .\BL\porn\urls /prependstar

2 – No ISA Server 2006, Criar em c:\Blacklist o primeiro arquivo .vbs obrigatoriamente com o nome: ISA_Fill_URL_Set.vbs

'*************************************************************************************
' Script Name: ISA_Fill_URL_Set.vbs
' Version: 1.3
' Author: Jason Fossen ( http://www.ISAscripts.org )
'Last Updated: 10.Jun.2008
' Purpose: Automatically update an ISA Server URL Set with URLs; for example,
' these could be URLs of spammers, pornographers, hacking sites, etc.
' Arguments: First arg is name of URL Set, in double-quotes if necessary. The
' second arg is the HTTP URL, local full path, or file name (if in same
' folder as script) of a text file containing the URL data. This file,
' if it contains comments, must use #-marks or semicolons to denote comments.
' Each line must be just one URL.
' This script is compatible with the lists at http://www.urlblacklist.com and
' with other similarly-formatted lists of URLs. The file with URLs can
' use either Windows-style or UNIX-style newlines, both work fine.
' Note: The fastest way to see that the URL Set had been filled correctly
' is to close and open the ISA MMC console again, not by refreshing.
' Works on both ISA Standard and Enterprise editions.
' Thanks to Alexander Willacker for the /*pendstar switches!
' Legal: Public Domain. Modify and redistribute freely. No rights reserved.
' SCRIPT PROVIDED "AS IS" WITHOUT WARRANTIES OR GUARANTEES OF ANY KIND.
' USE AT YOUR OWN RISK. Test on non-production servers first!
'*************************************************************************************

Option Explicit
On Error Resume Next

ReDim aURLsArray(0) 'Array of URLs to be added to the URL Set.
Dim sUrlSetName 'Name of URL Set to be created and/or updated.
Dim bUseLocalURLsFile 'If true, use local file. If false, get URLs from http URL.
Dim sURLsFilePath 'An HTTP URL or a local filesystem path to a file of URLs.
Dim oFPC 'See MakeIsaObjects()
Dim oIsaArray 'See MakeIsaObjects()
Dim bAppendStar : bAppendStar = False 'Assume that a trailing asterisk should not be added.
Dim bPrependStar : bPrependStar = False 'Assume that a leading asterisk & dot should not be added.

Dim oFileSystem : Set oFileSystem = WScript.CreateObject("Scripting.FileSystemObject")
Call CatchAnyErrorsAndQuit("Problems creating the FileSystemObject.")

'*************************************************************************************
' Main()
'*************************************************************************************
Call ProcessCommandLineArguments()
Call CreateIsaObjects()
Call MakeArrayOfURLs()
Call CreateUrlSet()
Call EmptyTheUrlSet()
Call CreateNewURLs()

'*************************************************************************************
' Procedures
'*************************************************************************************

Sub ProcessCommandLineArguments()
On Error Resume Next
'
' First arg...
'
sUrlSetName = WScript.Arguments.Item(0)
Dim sArg : sArg = LCase(sUrlSetName)
If (WScript.Arguments.Count = 0) Or (WScript.Arguments.Count > 4) Or (sArg = "/?")_
Or (sArg = "-?") Or (sArg = "/h") Or (sArg = "/help") Or (sArg = "--help") Then
Call ShowHelpAndQuit()
End If

'
' Second arg...
'
sURLsFilePath = WScript.Arguments.Item(1)

If InStr(LCase(sURLsFilePath), "http://") = 0 Then
bUseLocalURLsFile = True 'Use a local text file.
Else
bUseLocalURLsFile = False 'Use an http URL.
End If

'
' Check to see whether a trailing asterisk should be added if not already present.
'
For Each sArg In WScript.Arguments
If LCase(sArg) = "/appendstar" Then bAppendStar = True
Next

'
' Check to see whether a leading asterisk should be added if not already present.
'
For Each sArg In WScript.Arguments
If LCase(sArg) = "/prependstar" Then bPrependStar = True
Next

On Error Goto 0
End Sub

Sub CreateIsaObjects()
'This sub is just a placeholder for something to add later on...
Set oFPC = CreateObject("FPC.Root")
Set oIsaArray = oFPC.GetContainingArray
Call CatchAnyErrorsAndQuit("Problems connecting to ISA Server or ISA Array.")
End Sub

Sub MakeArrayOfURLs()
If bUseLocalURLsFile Then
If Not ParseInputFile(sURLsFilePath, aURLsArray) Then
Err.Raise -1
Call CatchAnyErrorsAndQuit("Problems reading the local URLs file: " & sURLsFilePath)
End If
Else 'Get the URLs file from the http URL...
Dim sUrlText : sUrlText = HttpGetText(sURLsFilePath)
If InStr(sUrlText, "GET-Error!") 0 Then ' "GET-Error!" would be returned by HttpGetText() function, not the web server.
Err.Raise -1
Call CatchAnyErrorsAndQuit("Problems getting URLs file from " & sUrlToURLsFile)
End If

If oFileSystem.FileExists("URLs-downloaded-from-url.txt") Then
oFileSystem.DeleteFile "URLs-downloaded-from-url.txt", True 'Delete prior URLs file, if it exists.
End If

If Not AppendToFile(sUrlText, "URLs-downloaded-from-url.txt") Then
Err.Raise -1
Call CatchAnyErrorsAndQuit("Problems writing to the URLs-downloaded-from-url.txt file.")
End If

If Not ParseInputFile("URLs-downloaded-from-url.txt", aURLsArray) Then
Err.Raise -1
Call CatchAnyErrorsAndQuit("Problems reading file: URLs-downloaded-from-url.txt")
End If
End If

End Sub

Sub CreateUrlSet()
On Error Resume Next
Dim cUrlSets 'FPCUrlSets collection.
Dim oUrlSet 'FPCUrlSet object.

'Set oFPC = CreateObject("FPC.Root")
'Set oIsaArray = oFPC.GetContainingArray
Set cUrlSets = oIsaArray.RuleElements.UrlSets

Set oUrlSet = cUrlSets.Add(sUrlSetName)

If Err.Number = -2147024713 Then
Err.Clear 'Already exists, so ignore error.
Else
cUrlSets.Save
End If

Call CatchAnyErrorsAndQuit("Problems recreating URL Set named " & sUrlSetName)
On Error Goto 0
End Sub

Sub EmptyTheUrlSet()
'Note: Clear the URL Set instead of deleting it because it may be used in rules already.
Dim cUrlSets 'FPCUrlSets collection.
Dim cUrlSet 'FPCUrlSet collection.
Dim sURL

'Set oFPC = CreateObject("FPC.Root")
'Set oIsaArray = oFPC.GetContainingArray
Set cUrlSet = oIsaArray.RuleElements.UrlSets.Item(sUrlSetName)

For Each sURL In cUrlSet
cUrlSet.Remove(sURL)
Next

cUrlSet.Save

Call CatchAnyErrorsAndQuit("Problems emptying URL Set named " & sUrlSetName)
End Sub

Sub CreateNewURLs()
On Error Resume Next
Dim cURLs 'FPCURLSets collection.
Dim oURL 'FPCURL object.
Dim cUrlSet 'FPCUrlSet collection.
Dim cUrlSets 'FPCUrlSets collection.
Dim sIPaddress, sMask, sURL, sURLName, sLeftChar

Set cUrlSet = oIsaArray.RuleElements.UrlSets.Item(sUrlSetName)

For Each sURL In aURLsArray
If Len(sURL) 0 Then
sLeftChar = Left(sURL,1)
If (sLeftChar "#") And (sLeftChar ";") And (sLeftChar "<") Then

If bAppendStar Then
'It might seem strange, but appending an asterisk to the end seems not to interfere with any
'other matching, and is probably the behavior most admins want anyway. It even works fine
'when you get entries like "www.domain.com*" and "www.domain.com/folder/file.html*".

sURL = sURL & "*" 'Append an asterisk to the end.
sURL = Replace(sURL, "**", "*") 'Correct if last char was already an asterisk.
End If

cUrlSet.Add(sURL)

If Err.Number = -2147024713 Then Err.Clear 'URL already added, so ignore error.
'WScript.Echo sURL & " was added." 'For debugging...

If bPrependStar Then
'Blocking devil.com will not block http://www.devil.com and vice versa. So every Domain
'should be added as *.devil.com and devil.com

sURL = "*." & sURL 'Preppend an asterisk & dot at the beginning.
sURL = Replace(sURL, "*.*.", "*.") 'Correct if first chars were already an asterisk & dot.

cUrlSet.Add(sURL)

If Err.Number = -2147024713 Then Err.Clear 'URL already added, so ignore error.
'WScript.Echo sURL & " was added." 'For debugging...

End If
End If
End If
Next

cUrlSet.Save

Call CatchAnyErrorsAndQuit("Problems creating new URL objects in " & sUrlSetName)
On Error Goto 0
End Sub

Sub CatchAnyErrorsAndQuit(sMessage)
Dim oStdErr
If Err.Number 0 Then
Set oStdErr = WScript.StdErr 'Write to standard error stream.
oStdErr.WriteLine vbCrLf
oStdErr.WriteLine ">>>>>> ERROR: " & sMessage
oStdErr.WriteLine "Error Number: " & Err.Number
oStdErr.WriteLine " Description: " & Err.Description
oStdErr.WriteLine "Error Source: " & Err.Source
oStdErr.WriteLine " Script Name: " & WScript.ScriptName
oStdErr.WriteLine vbCrLf
WScript.Quit Err.Number
End If
End Sub

Sub ShowHelpAndQuit()
Dim sUsage : sUsage = vbCrLf
sUsage = sUsage & vbCrLf
sUsage = sUsage & "ISA_FILL_URL_SET.VBS UrlSetName FilePath [/appendstar] [/prependstar]" & vbCrLf
sUsage = sUsage & vbCrLf
sUsage = sUsage & "Creates or updates an ISA Server URL Set (`UrlSet`)" & vbCrLf
sUsage = sUsage & "with the URLs from a text file (`FilePath`) obtained from" & vbCrLf
sUsage = sUsage & "either an HTTP URL or a local filesystem path." & vbCrLf
sUsage = sUsage & vbCrLf
sUsage = sUsage & " UrlSet Name of URL Set to be created or" & vbCrLf
sUsage = sUsage & " updated with URL entries. " & vbCrLf
sUsage = sUsage & vbCrLf
sUsage = sUsage & " FilePath A full HTTP URL or local filesystem path" & vbCrLf
sUsage = sUsage & " to a text file containing URLs. All" & vbCrLf
sUsage = sUsage & " comments must start with # or ;. Examples" & vbCrLf
sUsage = sUsage & " might be `filename.txt`, `c:\filename.txt`," & vbCrLf
sUsage = sUsage & " or `http://www.fqdn.com/filename.asp`." & vbCrLf
sUsage = sUsage & vbCrLf
sUsage = sUsage & " /appendstar Optional. Will automatically append an asterisk" & vbCrLf
sUsage = sUsage & " to every URL imported (which is probably what" & vbCrLf
sUsage = sUsage & " you want). Don't worry, this doesn't break" & vbCrLf
sUsage = sUsage & " URL matching when no path, or a full path, is" & vbCrLf
sUsage = sUsage & " specified in the URL, e.g., isascripts.org* and" & vbCrLf
sUsage = sUsage & " isascripts.org/index.html* still match fine." & vbCrLf
sUsage = sUsage & vbCrLf
sUsage = sUsage & " /prependstar Optional. Will automatically prepend an asterisk & dot" & vbCrLf
sUsage = sUsage & " to every URL imported. (e.g. Blocking devil.com will" & vbcrlf
sUsage = sUsage & " not block http://www.devil.com and vice versa. So every Domain" & vbcrlf
sUsage = sUsage & " will be added as *.devil.com and devil.com" & vbCrLf
sUsage = sUsage & vbCrLf
sUsage = sUsage & "Note that all URLs defined in the URL Set are deleted" & vbCrLf
sUsage = sUsage & "prior to importing the URLs from the text file. If necessary," & vbCrLf
sUsage = sUsage & "the URL Set object will be created first. Place double-quotes" & vbCrLf
sUsage = sUsage & "around the UrlSet and FilePath arguments if they contain" & vbCrLf
sUsage = sUsage & "any space characters. When providing an HTTP URL, the downloaded" & vbCrLf
sUsage = sUsage & "file will be saved as 'URLs-downloaded-from-url.txt` in the " & vbCrLf
sUsage = sUsage & "same folder as the script; it will be overwritten whenever a URL" & vbCrLf
sUsage = sUsage & "path is used again." & vbCrLf
sUsage = sUsage & vbCrLf
sUsage = sUsage & "Public domain. No rights reserved. SCRIPT PROVIDED ""AS IS"" WITHOUT WARRANTIES" & vbCrLf
sUsage = sUsage & "OR GUARANTEES OF ANY KIND. USE AT YOUR OWN RISK. ( http://www.ISAscripts.org )" & vbCrLf
sUsage = sUsage & vbCrLf

WScript.Echo sUsage
WScript.Quit
End Sub

'*************************************************************************************
' Functions
'*************************************************************************************

Function IsIpAddress(sInput)
'Regular expression would be more accurate, but slower...quick-n-dirty will do since
'having a "*.dottedIPaddress" URL doesn't break anything if an IP address sneaks by...

IsIpAddress = False

Dim sEnd
sInput = LCase(sInput)
sEnd = Right(sInput,1) 'This will catch 98% of cases, so it's faster than RegEx.
If (sEnd = "m") Or (sEnd = "u") Or (sEnd = "l") Or (sEnd = "v") Or (sEnd = "g")_
Or (sEnd = "t") Or (sEnd = "z") Or (sEnd = "o") Or (sEnd = "e") Or (sEnd = "s")_
Or (sEnd = "r") Or (sEnd = "n") Or (sEnd = "c") Or (sEnd = "k") Or (sEnd = "e") Then Exit Function

Dim aArray, x
aArray = Split(sInput,".")
If UBound(aArray) 3 Then Exit Function

If Not (IsNumeric(aArray(0)) And IsNumeric(aArray(1)) And IsNumeric(aArray(2)) And IsNumeric(aArray(3))) Then Exit Function

IsIpAddress = True
End Function

Function HttpGetText(sURL)
On Error Resume Next

If Not IsObject(oHTTP) Then Dim oHTTP : Set oHTTP = WScript.CreateObject("Microsoft.XMLHTTP")

oHTTP.Open "GET", sURL, False 'False = Script waits until the full HTTP response is received.
oHTTP.Send 'Send the HTTP command as defined with the Open method.

If Err.Number = 0 Then
HttpGetText = oHTTP.ResponseText
HttpGetText = Replace(HttpGetText, vbLf, vbCrLf) 'Flip UNIX new lines to DOS, if necessary.
Else
HttpGetText = "GET-Error! Error Number: " & Err.Number
End If
End Function

'*********************************************************************************
' Script Name: Parse_Input_File.vbs
' Version: 1.1
' Author: Jason Fossen
'Last Updated: 29.Mar.2004
' Purpose: Sorts lines of a text file into an array.
' Usage: Function returns true if no problems, false otherwise. Pass global
' variable of an array into second argument of function; this will be
' resized and populated with lines from text file. Blank and empty
' trailing lines from file, if any, are excluded from the array. The
' array global variable must be declared with "ReDim", not just "Dim".
' The file can be passed in with full path or just the file name if
' the file is in the same folder as the script.
' Note: You must declare the global array variable with "ReDim" before
' passing it into the function; make it of size one because it
' will be ReDim-ed without preservation again anyway.
' Legal: Public Domain. Modify and redistribute freely. No rights reserved.
' Use at your own risk. Do not run on networks for which you do not
' have prior written permission to do so. Script provided "AS IS".
'*********************************************************************************

Function ParseInputFile(ByVal sFile, ByRef aArray)
On Error Resume Next
Const ForReading = 1
Const OpenUsingDefault = -2
Dim sCurrentFolder, oFileSystem, oInputFile, i, iCurrentSize
Dim iPreserveCounter, oFile, oTextStream, iLineCount, sLine

'Expand environmental variables, if any.
If InStr(sFile, "%") 0 Then
If Not IsObject(oWshShell) Then Set oWshShell = WScript.CreateObject("WScript.Shell")
sFile = oWshShell.ExpandEnvironmentStrings(sFile)
End If

'Assume input file is in current folder if a full path is not given.
If InStr(sFile, "\") = 0 Then
sCurrentFolder = WScript.ScriptFullName
sCurrentFolder = Left(sCurrentFolder, InstrRev(sCurrentFolder, "\"))
sFile = sCurrentFolder & sFile
End If

'Verify that file exists and is readable, return false if not.
If Not IsObject(oFileSystem) Then Set oFileSystem = WScript.CreateObject("Scripting.FileSystemObject")
Set oFile = oFileSystem.GetFile(sFile)
Set oTextStream = oFile.OpenAsTextStream(ForReading, OpenUsingDefault)
If Err.Number 0 Then
'WScript.Echo "Problem opening " & sFile & " (" & Err.Description & ")"
ParseInputFile = False
Exit Function
End If

'Count the number of lines in file, not including an empty line at the very end (if present).
iLineCount = 0
Do While Not oTextStream.AtEndOfStream
oTextStream.SkipLine
iLineCount = iLineCount + 1
Loop

'ReDim the array to be equal to expected size of the input from file.
If iLineCount 0 Then
ReDim aArray(iLineCount - 1)
oTextStream.Close
Set oTextStream = Nothing
Else 'The input file was empty!
ReDim aArray(0)
'aArray(0) = "" 'Assign default here if desired.
oTextStream.Close
Set oTextStream = Nothing
Set oFile = Nothing
Set oFileSystem = Nothing
If Err.Number = 0 Then
ParseInputFile = True
Else
ParseInputFile = False
End If
Exit Function
End If

'Read each line of file into an element of the array, excluding blank lines.
Set oTextStream = oFile.OpenAsTextStream(ForReading, OpenUsingDefault)
i = 0
iPreserveCounter = 0
Do While Not oTextStream.AtEndOfStream
sLine = Trim(oTextStream.ReadLine) 'Note the trimming here.
If Len(sLine) 0 Then
aArray(i) = sLine
i = i + 1
Else
iPreserveCounter = iPreserveCounter + 1 'Keep track of blank lines.
End If
Loop
oTextStream.Close
Set oTextStream = Nothing

'If there were blank lines in the file, trim the array of empty elements.
If iPreserveCounter 0 Then
iCurrentSize = UBound(aArray)
ReDim Preserve aArray(iCurrentSize - iPreserveCounter)
End If

Set oFile = Nothing
Set oFileSystem = Nothing

If Err.Number = 0 Then
ParseInputFile = True
Else
ParseInputFile = False
End If
End Function

'**********************************************************************************
' Script Name: Append_To_File.vbs
' Version: 1.3
' Author: Jason Fossen
'Last Updated: 28.Jul.2004
' Purpose: Function to append line(s) to the end of a text file.
' If the file does not exist, it will be created. If the full
' path to the file is not supplied, it is assumed to be in the
' same folder as the script. Function returns true if no
' errors, false otherwise.
' Notes: Because this function would repeatedly open and close the file,
' this function is not appropriate for writing many lines to a single
' file one line at a time. Many megs of text can be appended in one shot.
' Legal: Public Domain. Modify and redistribute freely. No rights reserved.
'**********************************************************************************

Function AppendToFile(sData, sFile)
On Error Resume Next

Const ForAppending = 8 'Request NTFS appending permission.
Const ForOverWriting = 2 'Request NTFS writing permission.
Const ForReading = 1 'Request NTFS read permission.
Const OpenAsASCII = 0 'ASCII text format.
Const OpenAsUnicode = -1 'Unicode text format.
Const OpenUsingDefault = -2 'ASCII is default for FAT32, Unicode default for NTFS.

Dim sCurrentFolder, oTextStream

'Create FileSystemObject if it doesn't exist yet.
If Not IsObject(oFileSystem) Then Set oFileSystem = WScript.CreateObject("Scripting.FileSystemObject")

'Expand any environmental variables to their full paths.
If InStr(sFile, "%") 0 Then
If Not IsObject(oWshShell) Then Set oWshShell = WScript.CreateObject("WScript.Shell")
sFile = oWshShell.ExpandEnvironmentStrings(sFile)
End If

'Use current folder of script for output file path, if not path is given.
If InStr(sFile, "\") = 0 Then
sCurrentFolder = WScript.ScriptFullName
sCurrentFolder = Left(sCurrentFolder, InstrRev(sCurrentFolder, "\"))
sFile = sCurrentFolder & sFile
End If

'Get output file if it exists, or create one if it doesn't.
If Not oFileSystem.FileExists(sFile) Then
Set oTextStream = oFileSystem.CreateTextFile(sFile)
Else
Set oFile = oFileSystem.GetFile(sFile)
Set oTextStream = oFile.OpenAsTextStream(ForAppending, OpenUsingDefault)
End If

'Must write data to a new line, so check the column number first.
If oTextStream.Column = 1 Then
oTextStream.Write(sData)
Else
oTextStream.WriteBlankLines(1)
oTextStream.Write(sData)
End If

oTextStream.Close

If Err.Number = 0 Then
AppendToFile = True
Else
AppendToFile = False
End If
End Function

'END OF SCRIPT************************************************************************

3 – No ISA Server 2006, Criar em c:\Blacklist o segundo arquivo .vbs obrigatoriamente com o nome: ISA_Fill_Domain_Name_Set.vbs

'*************************************************************************************
' Script Name: ISA_Fill_Domain_Name_Set.vbs
' Version: 1.2
' Author: Jason Fossen ( http://www.ISAscripts.org )
'Last Updated: 18.Feb.2008
' Purpose: Automatically update an ISA Server Domain Name Set with domains; for example,
' these could be domains of spammers, pornographers, hacking sites, etc.
' Arguments: First arg is name of Domain Name Set, in double-quotes if necessary. The
' second arg is the HTTP URL, local full path, or file name (if in same
' folder as script) of a text file containing the domain data. This file,
' if it contains comments, must use #-marks or semicolons to denote comments.
' Each line must be just a domain name, but if IP addresses are in the list, they
' will be ignored automatically. This script is compatible with, but does not
' require or depend on, the lists at:
' http://urlblacklist.com
' http://www.squidguard.org/blacklists/
' It also works if a listed domain begins or ends with a period, or begins
' with "*." as a wildcard. The file with the domains can use either
' Windows-style or UNIX-style newlines, it's compatible with both. Note that
' each domain will be added twice: once with a prepended "*." and another
' without the leading "*." wildcard, since ISA won't match on just the plain
' domain name in a URL if the domain has "*." prepended to it in the set.
' Note: Depending on the speed of the ISA box, importing a 10MB file with 500,000
' domains can take between two and four hours. This is a bottleneck imposed
' by ISA, not the Windows Script Host or VBScript. Hence, schedule your
' imports during off-peak hours and run the script with the Start command
' to launch it with a lower multi-tasking priority; for example, like this:
' "start /belownormal cscript.exe ImportBlacklist.vbs Bad-Sites domains"
' Note: The fastest way to see that the Domain Name Set had been filled correctly
' is to close and open the ISA MMC console again, not by refreshing.
' Works on both ISA Standard and Enterprise.
' Legal: Public Domain. Modify and redistribute freely. No rights reserved.
' SCRIPT PROVIDED "AS IS" WITHOUT WARRANTIES OR GUARANTEES OF ANY KIND.
' USE AT YOUR OWN RISK. Test on non-production servers first!
'*************************************************************************************

Option Explicit
On Error Resume Next

ReDim aDomainsArray(0) 'Array of Domains to be added to the Domain Name Set.
Dim sDomainNameSetName 'Name of Domain Name Set to be created and/or updated.
Dim bUseLocalDomainsFile 'If true, use local file. If false, get domains from http URL.
Dim sDomainsFilePath 'An HTTP URL or a local filesystem path to a file of domains.
Dim oFPC 'See MakeIsaObjects()
Dim oIsaArray 'See MakeIsaObjects()

Dim oFileSystem : Set oFileSystem = WScript.CreateObject("Scripting.FileSystemObject")
Call CatchAnyErrorsAndQuit("Problems creating the FileSystemObject.")

'*************************************************************************************
' Main()
'*************************************************************************************
Call ProcessCommandLineArguments()
Call CreateIsaObjects()
Call MakeArrayOfDomains()
Call CreateDomainNameSet()
Call EmptyTheDomainNameSet()
Call CreateNewDomains()

'*************************************************************************************
' Procedures
'*************************************************************************************

Sub ProcessCommandLineArguments()
On Error Resume Next
'
' First arg...
'
sDomainNameSetName = WScript.Arguments.Item(0)
Dim sArg : sArg = LCase(sDomainNameSetName)
If (WScript.Arguments.Count = 0) Or (WScript.Arguments.Count => 3) Or (sArg = "/?")_
Or (sArg = "-?") Or (sArg = "/h") Or (sArg = "/help") Or (sArg = "--help") Then
Call ShowHelpAndQuit()
End If

'
' Second arg...
'
sDomainsFilePath = WScript.Arguments.Item(1)

If InStr(LCase(sDomainsFilePath), "http://") = 0 Then
bUseLocalDomainsFile = True 'Use a local text file.
Else
bUseLocalDomainsFile = False 'Use an http URL.
End If
On Error Goto 0
End Sub

Sub CreateIsaObjects()
'This sub is just a placeholder for something to add later on...
Set oFPC = CreateObject("FPC.Root")
Set oIsaArray = oFPC.GetContainingArray
Call CatchAnyErrorsAndQuit("Problems connecting to ISA Server or ISA Array.")
End Sub

Sub MakeArrayOfDomains()
If bUseLocalDomainsFile Then
If Not ParseInputFile(sDomainsFilePath, aDomainsArray) Then
Err.Raise -1
Call CatchAnyErrorsAndQuit("Problems reading the local domains file: " & sDomainsFilePath)
End If
Else 'Get the domains file from the http URL...
Dim sUrlText : sUrlText = HttpGetText(sDomainsFilePath)
If InStr(sUrlText, "GET-Error!") 0 Then ' "GET-Error!" would be returned by HttpGetText() function, not the web server.
Err.Raise -1
Call CatchAnyErrorsAndQuit("Problems getting domains file from " & sUrlToDomainsFile)
End If

If oFileSystem.FileExists("domains-downloaded-from-url.txt") Then
oFileSystem.DeleteFile "domains-downloaded-from-url.txt", True 'Delete prior domains file, if it exists.
End If

If Not AppendToFile(sUrlText, "domains-downloaded-from-url.txt") Then
Err.Raise -1
Call CatchAnyErrorsAndQuit("Problems writing to the domains-downloaded-from-url.txt file.")
End If

If Not ParseInputFile("domains-downloaded-from-url.txt", aDomainsArray) Then
Err.Raise -1
Call CatchAnyErrorsAndQuit("Problems reading file: domains-downloaded-from-url.txt")
End If
End If

End Sub

Sub CreateDomainNameSet()
On Error Resume Next
Dim cDomainNameSets 'FPCDomainNameSets collection.
Dim oDomainNameSet 'FPCDomainNameSet object.

'Set oFPC = CreateObject("FPC.Root")
'Set oIsaArray = oFPC.GetContainingArray
Set cDomainNameSets = oIsaArray.RuleElements.DomainNameSets

Set oDomainNameSet = cDomainNameSets.Add(sDomainNameSetName)

If Err.Number = -2147024713 Then
Err.Clear 'Already exists, so ignore error.
Else
cDomainNameSets.Save
End If

Call CatchAnyErrorsAndQuit("Problems recreating Domain Name Set named " & sDomainNameSetName)
On Error Goto 0
End Sub

Sub EmptyTheDomainNameSet()
'Note: Clear the Domain Name Set instead of deleting it because it may be used in rules already.
Dim cDomainNameSets 'FPCDomainNameSets collection.
Dim cDomainNameSet 'FPCDomainNameSet collection.
Dim sDomain

'Set oFPC = CreateObject("FPC.Root")
'Set oIsaArray = oFPC.GetContainingArray
Set cDomainNameSet = oIsaArray.RuleElements.DomainNameSets.Item(sDomainNameSetName)

For Each sDomain In cDomainNameSet
cDomainNameSet.Remove(sDomain)
Next

cDomainNameSet.Save

Call CatchAnyErrorsAndQuit("Problems emptying Domain Name Set named " & sDomainNameSetName)
End Sub

Sub CreateNewDomains()
On Error Resume Next
Dim cDomains 'FPCURLSets collection.
Dim oDomain 'FPCDomain object.
Dim cDomainNameSet 'FPCDomainNameSet collection.
Dim cDomainNameSets 'FPCDomainNameSets collection.
Dim sIPaddress, sMask, sDomain, sDomainName

Set cDomainNameSet = oIsaArray.RuleElements.DomainNameSets.Item(sDomainNameSetName)

For Each sDomain In aDomainsArray
If (Left(sDomain, 1) "#") And (Left(sDomain, 1) ";") And (Left(sDomain, 1) "<") And (Len(sDomain) 0) And Not IsIpAddress(sDomain) Then
If Right(sDomain,1) = "." Then sDomain = Left(sDomain, Len(sDomain) - 1) 'Trim off a trailing period, if present.
If Left(sDomain,2) "*." Then sDomain = "*." & sDomain 'Prepend "*." if not already there.
sDomain = Replace(sDomain, "..", ".") 'Correct if first char was already a period.
cDomainNameSet.Add(sDomain)
If Err.Number = -2147024713 Then Err.Clear 'Domain already added, so ignore error.

'Comment out the next three lines if you don't want the plain "domain.com" entries added too (the ones without the leading "*.").
sDomain = Trim(Replace(sDomain, "*.", ""))
cDomainNameSet.Add(sDomain)
If Err.Number = -2147024713 Then Err.Clear 'Domain already added, so ignore error.
End If
Next

cDomainNameSet.Save

Call CatchAnyErrorsAndQuit("Problems creating new domain objects in " & sDomainNameSetName)
On Error Goto 0
End Sub

Sub CatchAnyErrorsAndQuit(sMessage)
Dim oStdErr
If Err.Number 0 Then
Set oStdErr = WScript.StdErr 'Write to standard error stream.
oStdErr.WriteLine vbCrLf
oStdErr.WriteLine ">>>>>> ERROR: " & sMessage
oStdErr.WriteLine "Error Number: " & Err.Number
oStdErr.WriteLine " Description: " & Err.Description
oStdErr.WriteLine "Error Source: " & Err.Source
oStdErr.WriteLine " Script Name: " & WScript.ScriptName
oStdErr.WriteLine vbCrLf
WScript.Quit Err.Number
End If
End Sub

Sub ShowHelpAndQuit()
Dim sUsage : sUsage = vbCrLf
sUsage = sUsage & vbCrLf
sUsage = sUsage & "ISA_FILL_DOMAIN_NAME_SET.VBS DomainNameSetName FilePath" & vbCrLf
sUsage = sUsage & vbCrLf
sUsage = sUsage & "Creates or updates an ISA Server Domain Name Set (`DomainNameSet`)" & vbCrLf
sUsage = sUsage & "with the domains from a text file (`FilePath`) obtained from" & vbCrLf
sUsage = sUsage & "either an HTTP URL or a local filesystem path." & vbCrLf
sUsage = sUsage & vbCrLf
sUsage = sUsage & " DomainNameSet Name of Domain Name Set to be created or" & vbCrLf
sUsage = sUsage & " updated with domain entries. Will be" & vbCrLf
sUsage = sUsage & " created in the local ISA Server or" & vbCrLf
sUsage = sUsage & " current ISA Server Array." & vbCrLf
sUsage = sUsage & vbCrLf
sUsage = sUsage & " FilePath A full HTTP URL or local filesystem path" & vbCrLf
sUsage = sUsage & " to a text file containing domains. All" & vbCrLf
sUsage = sUsage & " comments must start with # or ;. Examples" & vbCrLf
sUsage = sUsage & " might be `filename.txt`, `c:\filename.txt`," & vbCrLf
sUsage = sUsage & " or `http://www.fqdn.com/filename.asp`." & vbCrLf
sUsage = sUsage & vbCrLf
sUsage = sUsage & "Note that all domains defined in the Domain Name Set are deleted" & vbCrLf
sUsage = sUsage & "prior to importing the domains from the text file. If necessary," & vbCrLf
sUsage = sUsage & "the Domain Name Set object will be created. Place double-quotes" & vbCrLf
sUsage = sUsage & "around the DomainNameSet and FilePath arguments if they contain" & vbCrLf
sUsage = sUsage & "any space characters. When providing an HTTP URL, the downloaded" & vbCrLf
sUsage = sUsage & "file will be saved as 'domains-downloaded-from-url.txt` in the " & vbCrLf
sUsage = sUsage & "same folder as the script; it will be overwritten whenever a URL" & vbCrLf
sUsage = sUsage & "path is used again. Script must be run on the ISA Server itself." & vbCrLf
sUsage = sUsage & vbCrLf
sUsage = sUsage & "SCRIPT PROVIDED ""AS IS"" AND WITHOUT WARRANTIES OR GUARANTEES OF ANY KIND." & vbCrLf
sUsage = sUsage & "USE AT YOUR OWN RISK. ( http://www.ISAscripts.org )" & vbCrLf
sUsage = sUsage & vbCrLf

WScript.Echo sUsage
WScript.Quit
End Sub

'*************************************************************************************
' Functions
'*************************************************************************************

Function IsIpAddress(sInput)
'Regular expression would be more accurate, but slower...quick-n-dirty will do since
'having a "*.dottedIPaddress" domain doesn't break anything if an IP address sneaks by...

IsIpAddress = False

Dim sEnd
sInput = LCase(sInput)
sEnd = Right(sInput,1) 'This will catch 98% of cases, so it's faster than RegEx.
If (sEnd = "m") Or (sEnd = "u") Or (sEnd = "l") Or (sEnd = "v") Or (sEnd = "g")_
Or (sEnd = "t") Or (sEnd = "z") Or (sEnd = "o") Or (sEnd = "e") Or (sEnd = "s")_
Or (sEnd = "r") Or (sEnd = "n") Or (sEnd = "c") Or (sEnd = "k") Or (sEnd = "e") Then Exit Function

Dim aArray, x
aArray = Split(sInput,".")
If UBound(aArray) 3 Then Exit Function

If Not (IsNumeric(aArray(0)) And IsNumeric(aArray(1)) And IsNumeric(aArray(2)) And IsNumeric(aArray(3))) Then Exit Function

IsIpAddress = True
End Function

Function HttpGetText(sURL)
On Error Resume Next

If Not IsObject(oHTTP) Then Dim oHTTP : Set oHTTP = WScript.CreateObject("Microsoft.XMLHTTP")

oHTTP.Open "GET", sURL, False 'False = Script waits until the full HTTP response is received.
oHTTP.Send 'Send the HTTP command as defined with the Open method.

If Err.Number = 0 Then
HttpGetText = oHTTP.ResponseText
HttpGetText = Replace(HttpGetText, vbLf, vbCrLf) 'Flip UNIX new lines to DOS, if necessary.
Else
HttpGetText = "GET-Error! Error Number: " & Err.Number
End If
End Function

'*********************************************************************************
' Script Name: Parse_Input_File.vbs
' Version: 1.1
' Author: Jason Fossen
'Last Updated: 29.Mar.2004
' Purpose: Sorts lines of a text file into an array.
' Usage: Function returns true if no problems, false otherwise. Pass global
' variable of an array into second argument of function; this will be
' resized and populated with lines from text file. Blank and empty
' trailing lines from file, if any, are excluded from the array. The
' array global variable must be declared with "ReDim", not just "Dim".
' The file can be passed in with full path or just the file name if
' the file is in the same folder as the script.
' Note: You must declare the global array variable with "ReDim" before
' passing it into the function; make it of size one because it
' will be ReDim-ed without preservation again anyway.
' Legal: Public Domain. Modify and redistribute freely. No rights reserved.
' Use at your own risk. Do not run on networks for which you do not
' have prior written permission to do so. Script provided "AS IS".
'*********************************************************************************

Function ParseInputFile(ByVal sFile, ByRef aArray)
On Error Resume Next
Const ForReading = 1
Const OpenUsingDefault = -2
Dim sCurrentFolder, oFileSystem, oInputFile, i, iCurrentSize
Dim iPreserveCounter, oFile, oTextStream, iLineCount, sLine

'Expand environmental variables, if any.
If InStr(sFile, "%") 0 Then
If Not IsObject(oWshShell) Then Set oWshShell = WScript.CreateObject("WScript.Shell")
sFile = oWshShell.ExpandEnvironmentStrings(sFile)
End If

'Assume input file is in current folder if a full path is not given.
If InStr(sFile, "\") = 0 Then
sCurrentFolder = WScript.ScriptFullName
sCurrentFolder = Left(sCurrentFolder, InstrRev(sCurrentFolder, "\"))
sFile = sCurrentFolder & sFile
End If

'Verify that file exists and is readable, return false if not.
If Not IsObject(oFileSystem) Then Set oFileSystem = WScript.CreateObject("Scripting.FileSystemObject")
Set oFile = oFileSystem.GetFile(sFile)
Set oTextStream = oFile.OpenAsTextStream(ForReading, OpenUsingDefault)
If Err.Number 0 Then
'WScript.Echo "Problem opening " & sFile & " (" & Err.Description & ")"
ParseInputFile = False
Exit Function
End If

'Count the number of lines in file, not including an empty line at the very end (if present).
iLineCount = 0
Do While Not oTextStream.AtEndOfStream
oTextStream.SkipLine
iLineCount = iLineCount + 1
Loop

'ReDim the array to be equal to expected size of the input from file.
If iLineCount 0 Then
ReDim aArray(iLineCount - 1)
oTextStream.Close
Set oTextStream = Nothing
Else 'The input file was empty!
ReDim aArray(0)
'aArray(0) = "" 'Assign default here if desired.
oTextStream.Close
Set oTextStream = Nothing
Set oFile = Nothing
Set oFileSystem = Nothing
If Err.Number = 0 Then
ParseInputFile = True
Else
ParseInputFile = False
End If
Exit Function
End If

'Read each line of file into an element of the array, excluding blank lines.
Set oTextStream = oFile.OpenAsTextStream(ForReading, OpenUsingDefault)
i = 0
iPreserveCounter = 0
Do While Not oTextStream.AtEndOfStream
sLine = Trim(oTextStream.ReadLine) 'Note the trimming here.
If Len(sLine) 0 Then
aArray(i) = sLine
i = i + 1
Else
iPreserveCounter = iPreserveCounter + 1 'Keep track of blank lines.
End If
Loop
oTextStream.Close
Set oTextStream = Nothing

'If there were blank lines in the file, trim the array of empty elements.
If iPreserveCounter 0 Then
iCurrentSize = UBound(aArray)
ReDim Preserve aArray(iCurrentSize - iPreserveCounter)
End If

Set oFile = Nothing
Set oFileSystem = Nothing

If Err.Number = 0 Then
ParseInputFile = True
Else
ParseInputFile = False
End If
End Function

'**********************************************************************************
' Script Name: Append_To_File.vbs
' Version: 1.3
' Author: Jason Fossen
'Last Updated: 28.Jul.2004
' Purpose: Function to append line(s) to the end of a text file.
' If the file does not exist, it will be created. If the full
' path to the file is not supplied, it is assumed to be in the
' same folder as the script. Function returns true if no
' errors, false otherwise.
' Notes: Because this function would repeatedly open and close the file,
' this function is not appropriate for writing many lines to a single
' file one line at a time. Many megs of text can be appended in one shot.
' Legal: Public Domain. Modify and redistribute freely. No rights reserved.
'**********************************************************************************

Function AppendToFile(sData, sFile)
On Error Resume Next

Const ForAppending = 8 'Request NTFS appending permission.
Const ForOverWriting = 2 'Request NTFS writing permission.
Const ForReading = 1 'Request NTFS read permission.
Const OpenAsASCII = 0 'ASCII text format.
Const OpenAsUnicode = -1 'Unicode text format.
Const OpenUsingDefault = -2 'ASCII is default for FAT32, Unicode default for NTFS.

Dim sCurrentFolder, oTextStream

'Create FileSystemObject if it doesn't exist yet.
If Not IsObject(oFileSystem) Then Set oFileSystem = WScript.CreateObject("Scripting.FileSystemObject")

'Expand any environmental variables to their full paths.
If InStr(sFile, "%") 0 Then
If Not IsObject(oWshShell) Then Set oWshShell = WScript.CreateObject("WScript.Shell")
sFile = oWshShell.ExpandEnvironmentStrings(sFile)
End If

'Use current folder of script for output file path, if not path is given.
If InStr(sFile, "\") = 0 Then
sCurrentFolder = WScript.ScriptFullName
sCurrentFolder = Left(sCurrentFolder, InstrRev(sCurrentFolder, "\"))
sFile = sCurrentFolder & sFile
End If

'Get output file if it exists, or create one if it doesn't.
If Not oFileSystem.FileExists(sFile) Then
Set oTextStream = oFileSystem.CreateTextFile(sFile)
Else
Set oFile = oFileSystem.GetFile(sFile)
Set oTextStream = oFile.OpenAsTextStream(ForAppending, OpenUsingDefault)
End If

'Must write data to a new line, so check the column number first.
If oTextStream.Column = 1 Then
oTextStream.Write(sData)
Else
oTextStream.WriteBlankLines(1)
oTextStream.Write(sData)
End If

oTextStream.Close

If Err.Number = 0 Then
AppendToFile = True
Else
AppendToFile = False
End If
End Function

'END OF SCRIPT************************************************************************

4 – Baixar a blacklist shallalist.tar.gz e extrai-la em uma pasta temporária. Mover de dentro desse arquivo toda pasta BL para dentro do diretorio C:\Blacklist ficando assim… C:\Blacklist\BL\adv\domains (por exemplo, aonde adv é uma das tantas categorias)

5 – Finalizando

A bat Execute-Import-In-ISA2006.bat vai chamar dois scripts que vão iportar os dados da Blacklist baixada no site da Shalllist
Basta executa-la e aguardar que todas as blacklists sejam importadas.
Apos finalizar abra o ISA Server e crie as regras com as novas Desination URL_Sets e Domain_Name referentes as categorias que voce deseja bloquear ou liberar

Select Data Atual

julho 26, 2011

Caso seja necessário realizar a busca por um determinado valor do tipo DATE (DATA) filtrando pelo ano, mes ou dia atual podemos executar o script abaixo.
Supondo que minha tabela se chame ENTRADAS e a coluna contendo todos os dados referente a datas se chame Date
Filtrando pelo Mes atual em ordem Decrescente:
SELECT     TOP (1000) Date
FROM         Entradas
WHERE
(YEAR(Date) = YEAR(GETDATE())) AND (MONTH(Date) = MONTH(GETDATE()))
ORDER BY Date DESC
Filtrando pelo Dia atual em ordem Decrescente:
SELECT TOP (1000) Date
FROM Entradas
WHERE
(YEAR(Date) = YEAR(GETDATE())) AND (MONTH(Date) = MONTH(GETDATE())) AND (DAY(Date) = DAY(GETDATE()))
ORDER BY Date DESC

Pra quem pegou um vírus, precisou formatar o pc e só tinha o CD do Windows XP SP3, ou quis, por vontade própria, instalar o Service Pack 3  e depois de tudo tentou instalar sem sucesso oInternet Explorer 7 (IE7), a solução do problema é simples e não requer conhecimento técnico avançado.
A resolução do problema de não poder instalar o Internet Explorer 7 no Windows XP Service Pack 3 é simplesmente seguir os seguintes passos:

1º Abra o prompt de comando do windows (Inicia -> Executar) e digite o seguinte comando:

secedit /configure /cfg %windir%\repair\secsetup.inf /db secsetup.sdb /verbose

2º Após executar o comando uma tela preta do console do windows abrirá e fará automaticamente o reparo de possíveis problemas que impossibilitam a instalação do IE7 no SP3;

3º Agora é só tentar instalar o Internet Explorer 7 (IE7) e correr pro abraço