<?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/869.htm</link>
<title><![CDATA[启用网络适配器上的 IPSec]]></title> 
<author>gOxiA &lt;sufan_cn@msn.com&gt;</author>
<category><![CDATA[PowerShell 和脚本]]></category>
<pubDate>Sat, 09 Jul 2005 01:54:35 +0000</pubDate> 
<guid>https://maytide.net/read.php/869.htm</guid> 
<description>
<![CDATA[ 
	<span><div><p><strong>描述</strong></p></div><div><p>启用网络适配器的 IP 安全性。在此脚本中，所有的l TCP 和 UDP 端口以及所有的l IP 协议都是允许的；因此在每种情况下都传送值 0。如果只允许特定的端口或协议，则应该以数组的形式发送这些值。</p></div><div><p>有关在这段代码中使用的 EnableIPSec 方法的更多信息，请单击 <a href="http://msdn.microsoft.com/library/en-us/wmisdk/wmi/enableipsec_method_in_class_win32_networkadapterconfiguration.asp"><span style="color: #666666">此处</span></a>。</p></div><div><p><strong><br />支持平台</strong></p></div><table border="0" cellspacing="0" cellpadding="0" class="dataTable" id="EFAA"><thead></thead><tbody><tr class="record" valign="top"><td><p class="lastInCell"><strong>Windows Server 2003</strong></p></td><td style="border-right: #cccccc 1px solid"><p class="lastInCell"><strong>是</strong></p></td></tr><tr class="evenRecord" valign="top"><td><p class="lastInCell"><strong>Windows XP</strong></p></td><td style="border-right: #cccccc 1px solid"><p class="lastInCell"><strong>是</strong></p></td></tr><tr class="record" valign="top"><td><p class="lastInCell"><strong>Windows 2000</strong></p></td><td style="border-right: #cccccc 1px solid"><p class="lastInCell"><strong>是</strong></p></td></tr><tr class="evenRecord" valign="top"><td><p class="lastInCell"><strong>Windows NT 4.0</strong></p></td><td style="border-right: #cccccc 1px solid"><p class="lastInCell"><strong>Yes, with WMI installed</strong></p></td></tr></tbody></table><div><p></p><p><br /><strong>脚本代码<br /></strong>On Error Resume Next<br />Const ALLOW_ALL = 0<br />strComputer = &quot;.&quot;<br />Set objWMIService = GetObject(&quot;winmgmts:&#92;&#92;&quot; &amp; strComputer &amp; &quot;&#92;root&#92;cimv2&quot;)<br />Set colNetCards = objWMIService.ExecQuery _<br />&nbsp; &nbsp;(&quot;Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True&quot;)<br />For Each objNetCard in colNetCards<br />&nbsp; &nbsp;arrPermittedTCPPorts = Array(ALLOW_ALL)<br />&nbsp; &nbsp;arrPermittedUDPPorts = Array(ALLOW_ALL)<br />&nbsp; &nbsp;arrPermittedIPProtocols = Array(ALLOW_ALL)<br />&nbsp; &nbsp;objNetCard.EnableIPSec arrPermittedTCPPorts, arrPermittedUDPPorts, arrPermittedIPProtocols<br />Next<br /><br /></p><hr /><br /><strong>EnableIPSec Method of the Win32_NetworkAdapterConfiguration Class：<br /><br />uint32 EnableIPSec(&nbsp; <p></p><pre class="syntax"><strong>string IPSecPermitTCPPorts[],&nbsp; </strong></pre><pre class="syntax"><strong>string IPSecPermitUDPPorts[],&nbsp; </strong></pre><pre class="syntax"><strong>string IPSecPermitIPProtocols[]</strong></pre><pre class="syntax"><strong>);</strong></pre></strong></div></span>
]]>
</description>
</item>
</channel>
</rss>