标题:启用网络适配器上的 IPSec 出处:gOxiA=苏繁=SuFan Blog 时间:Sat, 09 Jul 2005 09:54:35 +0000 作者:gOxiA 地址:https://sufan.maytide.net/read.php/869.htm 内容: 描述 启用网络适配器的 IP 安全性。在此脚本中,所有的l TCP 和 UDP 端口以及所有的l IP 协议都是允许的;因此在每种情况下都传送值 0。如果只允许特定的端口或协议,则应该以数组的形式发送这些值。 有关在这段代码中使用的 EnableIPSec 方法的更多信息,请单击 此处。 支持平台 Windows Server 2003 是 Windows XP 是 Windows 2000 是 Windows NT 4.0 Yes, with WMI installed 脚本代码On Error Resume NextConst ALLOW_ALL = 0strComputer = "."Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")Set colNetCards = objWMIService.ExecQuery _ ("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")For Each objNetCard in colNetCards arrPermittedTCPPorts = Array(ALLOW_ALL) arrPermittedUDPPorts = Array(ALLOW_ALL) arrPermittedIPProtocols = Array(ALLOW_ALL) objNetCard.EnableIPSec arrPermittedTCPPorts, arrPermittedUDPPorts, arrPermittedIPProtocolsNext EnableIPSec Method of the Win32_NetworkAdapterConfiguration Class:uint32 EnableIPSec( string IPSecPermitTCPPorts[], string IPSecPermitUDPPorts[], string IPSecPermitIPProtocols[]); Generated by Bo-blog 2.1.1 Release