惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
The Blog of Author Tim Ferriss
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
云风的 BLOG
云风的 BLOG
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
P
Palo Alto Networks Blog
D
Docker
H
Hackread – Cybersecurity News, Data Breaches, AI and More
S
Schneier on Security
Engineering at Meta
Engineering at Meta
I
InfoQ
L
LangChain Blog
Cyberwarzone
Cyberwarzone
T
Tenable Blog
WordPress大学
WordPress大学
P
Privacy & Cybersecurity Law Blog
罗磊的独立博客
Apple Machine Learning Research
Apple Machine Learning Research
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Jina AI
Jina AI
C
CERT Recently Published Vulnerability Notes
Scott Helme
Scott Helme
博客园 - 三生石上(FineUI控件)
酷 壳 – CoolShell
酷 壳 – CoolShell
Know Your Adversary
Know Your Adversary
D
Darknet – Hacking Tools, Hacker News & Cyber Security
The Last Watchdog
The Last Watchdog
Last Week in AI
Last Week in AI
Cloudbric
Cloudbric
S
SegmentFault 最新的问题
爱范儿
爱范儿
Application and Cybersecurity Blog
Application and Cybersecurity Blog
博客园 - 叶小钗
AI
AI
T
Tor Project blog
I
Intezer
T
Threatpost
www.infosecurity-magazine.com
www.infosecurity-magazine.com
V
Visual Studio Blog
N
News and Events Feed by Topic
Latest news
Latest news
S
Security Affairs
博客园 - Franky
Microsoft Security Blog
Microsoft Security Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
B
Blog RSS Feed
C
Cybersecurity and Infrastructure Security Agency CISA
Hugging Face - Blog
Hugging Face - Blog
小众软件
小众软件
S
Securelist

博客园 - Johnny shen

XP 32-bit Upgrade to Win7 32-bit Review 文章: 扩展 Reporting Services 2008 与 Reporting Services 2005:所获得的经验 Microsoft SQL Server 2008故障转移群集在Hyper-V虚拟机上的多种组建方式 Hyper-v与CPU 虚拟化典型故障一例 MS Dynamics CRM 4.0 Installation on SQL2008 error 多个微软Windows版本在未来一年内将渐渐退出并不再提供技术支持 微软拼音输入法2010 Beta2简评 - Johnny shen SQL Server 2005 OLAP技术研究与实现 Storing Hierarchical Data in Oracle & MS SQL Database TCP/IP Troubleshooting Undo Windows Update Restriction - Johnny shen 苏州主讲[常见加密算法和身份验证协议探究] 上海主讲RMS信息保护 无锡主讲微软企业信息系统远程客户端安全技术和应用 AD Bulk import or export Enabling IP Routing for Windows XP On-site training for Roche Shanghai in Aug. 3 ASIA MVP Summit in Singapore ISA2004 EE Global Readness Training Camp
自动备份多台服务器System Event Log解决方案
Johnny shen · 2008-02-28 · via 博客园 - Johnny shen

审计需要备份公司多台Windows2000/2003成员服务器(DC在总部),并将其并入公司的数据自动备份方案中。
1. 考虑先用脚本实现备份过程,文件名eventlogsbackup.vbs.(脚本如下,其中需维护一服务器清单)
2. 建立一批文件Eventlogsbackup.bat, 包含语句cscript eventlogsbackup.vbs
3. Schedule a task 来用你的域帐户RunAs运行此批文件,当然之前你必须将此域帐号加入到能读写系统Event的用户组中.(用这种方法,你的域帐户的密码不用担心是明文而被看到)
4. 运行此任务,所有的服务器的Event logs数据将被集中备份到一点。

On Error Resume Next
Dim strDate
centralDumpPath = "\\Dserver\Eventlogs\"
RemoteDumpPath = "C:\EventLogs\"
arrLogs=Array("Application","System","Security")
Set oFS = CreateObject("Scripting.FileSystemObject")
Set WshShell = WScript.CreateObject("wscript.shell")
Set oTS = oFS.OpenTextFile("C:\EventLogs\serverlist.txt")
arrComputers=Split(Trim(oTS.ReadAll),VbCrLf)
oTS.Close
For Each sComputer In arrComputers
  if Len(sComputer)>0 Then 'skip any blank lines
      For Each strLog In arrLogs
          strDate = CStr(Date())
          strDate = Replace(strDate, "/", "-")
          remoteDumpFile =  UCase(sComputer) &_
           "-" & strLog & "-" & strDate & ".evt"  
          rc=BackupLog(strLog,remoteDumpPath & remoteDumpFile,sComputer)
              If rc(0)=0 Then
               strSource="\\" & sComputer & "\" & Replace(remoteDumpPath &_
                remoteDumpFile, "C:", "C$")
               strDestination=centralDumpPath & sComputer &_
                "\" & remoteDumpFile
               MoveFile strSource,strDestination
              Else
               Wscript.Echo "Couldn't get log " & strLog & " from " & sComputer &_
                ".  Error code: " & rc(0) & " " & rc(1)
              End If
      Next
    End If
Next
WScript.Quit

Function BackupLog(sLog,sFile,sComputer)
On Error Resume Next
Set oFS = CreateObject("Scripting.FileSystemObject")
If oFS.FileExists(sFile) Then oFS.DeleteFile sFile,True
 Set oWMIService = GetObject("winmgmts:" _
 & "{impersonationLevel=impersonate,(Security,Backup)}!\\" & _
 sComputer & "\root\cimv2")
Set cLogFiles = oWMIService.ExecQuery _
 ("Select * from Win32_NTEventLogFile where " & _
 "LogFileName='" & sLog & "'")
If cLogFiles.Count =0 Then
    BackupLog=Array("-1","Nothing to backup for event log " & sLog)
    Exit Function
End If
 For Each oLogfile in cLogFiles
   WScript.Echo "Creating " & sFile
    oLogFile.BackupEventLog(sFile)
  If Err.number=0 Then
    BackupLog=Array(0,"Successfully backed up " & sLog & " to " & sFile)
    wshshell.LogEvent 0, "Successfully backed up " & sLog & " log to " & sFile
   'no error - safe to clear the Log
   'WScript.Echo "Clearing event log " & strLog & " on " & sComputer
   'wshshell.LogEvent 0, "Clearing event log of " & strLog & " on " & sComputer
    'Uncomment the next line to actually clear the log. I have it
    'commented out for test purposes
   'oLogFile.ClearEventLog()
  Else
    BackupLog=Array(Err.Number,Err.Description)
    wshshell.LogEvent 0, "Failure on backed up " & sLog & " log to " & sFile
  End If
Next
End Function

Function MoveFile(strSource,strDestination)
On Error Resume Next
Set oFS = CreateObject("Scripting.FileSystemObject")
strParentFolder = oFS.GetParentFolderName(strDestination)
   If oFS.FolderExists(strParentFolder)=False Then
    WScript.Echo "Creating " & strParentFolder
    oFS.CreateFolder strParentFolder
        If Err.Number<>0 Then
            WScript.Echo "Failed to create " & strParentFolder
            Exit Function
        End If
   End If
    WScript.Echo "Copying " & strSource & " to " & strDestination
    oFS.CopyFile strSource,strDestination,True
    If Err.Number=0 Then oFS.DeleteFile strSource
End Function