<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[gOxiA=苏繁=SuFan Blog]]></title> 
<link>https://maytide.net/index.php</link> 
<description><![CDATA[gOxiA,苏繁,sufan,Microsoft MVP]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[gOxiA=苏繁=SuFan Blog]]></copyright>
<item>
<link>https://maytide.net/read.php/874.htm</link>
<title><![CDATA[备份和清除大型事件日志]]></title> 
<author>gOxiA &lt;sufan_cn@msn.com&gt;</author>
<category><![CDATA[PowerShell 和脚本]]></category>
<pubDate>Sat, 09 Jul 2005 02:02:35 +0000</pubDate> 
<guid>https://maytide.net/read.php/874.htm</guid> 
<description>
<![CDATA[ 
	<span><div><p><strong>描述</strong></p></div><div><p>如果事件日志文件的大小大于 20 MB，就将其备份和清除。</p></div><div><p><br /><strong>脚本代码<br /></strong>strComputer = &quot;.&quot;<br />Set objWMIService = GetObject(&quot;winmgmts:&quot; _<br />&nbsp; &nbsp;&amp; &quot;&#123; impersonationLevel=impersonate, (Backup, Security) &#125;!&#92;&#92;&quot; _<br />&nbsp; &nbsp; &nbsp; &nbsp;&amp; strComputer &amp; &quot;&#92;root&#92;cimv2&quot;)<br />Set colLogFiles = objWMIService.ExecQuery _<br />&nbsp; &nbsp;(&quot;Select * from Win32_NTEventLogFile&quot;)<br />For each objLogfile in colLogFiles<br />&nbsp; &nbsp;If objLogFile.FileSize &gt; 100000 Then<br />&nbsp; &nbsp; &nbsp; strBackupLog = objLogFile.BackupEventLog _<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (&quot;c:&#92;scripts&#92;&quot; &amp; objLogFile.LogFileName &amp; &quot;.evt&quot;)<br />&nbsp; &nbsp; &nbsp; objLogFile.ClearEventLog()<br />&nbsp; &nbsp;End If<br />Next</p></div></span>
]]>
</description>
</item>
</channel>
</rss>