Showing posts with label batch. Show all posts
Showing posts with label batch. Show all posts

Monday, February 22, 2010

AutoBackupEvent Logs and Move

1. Windows 2003/2008 server will archive the event logs when they become full (see url)
  • add these registry settings

Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\Application] "AutoBackupLogFiles"=dword:00000001 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\System] "AutoBackupLogFiles"=dword:00000001 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\Security] "AutoBackupLogFiles"=dword:00000001

2. Create Batch File to Move Archive to Different Drive and schedule daily task

REM Barry Schneider 20100155

moveLocation="[drive:\path]"

move /Y c:\windows\system32\config\Archive-*.evt %moveLocation%

3. Delete Logs After Retention Expires and create daily task

Dim fso, f, f1, fc, folder, ext

archiveFolder="Drive:\Path\"
fileExtension="evt"
Set fso = CreateObject("Scripting.FileSystemObject")

Set f = fso.GetFolder(archiveFolder)

Set fc = f.Files

For Each f1 in fc

fileExt = fso.GetExtensionName(f1.Path)

If fileExt = fileExtension Then

If DateDiff("d", f1.DateLastModified, Now) > 181 Then

f1.Delete

End If

End If

Next

Set fso = Nothing

Set f = Nothing

Set fc = Nothing

Modified iisweb.vbs to just list web applications

  1. find iisweb.vbs
  2. make a copy of iisweb.vbs
  3. rename
  4. modify

From:
bFirstIteration = True

To:
bFirstIteration = False

From:
line = Server.ServerComment & " (" & Server.Name & ")" & _
Space(firstLen) & strState & _
Space(secLen) & strIP & Space(thirdLen) & strPort & _
Space(fourthLen) & strHost

To:
line = strHost&":"&strPort

5. Save file

REM Barry Schneider 20100222
REM Add AD Group to all SharePoint Web Application with permissionlevel Full Control
REM List of Web Application are in the file ListWebApplication.txt
REM example http://www.msih.com

set stsadmPath="C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\BIN\"

FOR /F "tokens=1 delims= " %%G IN (ListWebApplication.txt) DO %stsadmPath%stsadm -o addpermissionpolicy -url %%G -userlogin [AD Group] -permissionlevel "Full Control"