启用网络适配器上的 IPSec

[ 2005/07/09 09:54 | by gOxiA ]
| |

描述

启用网络适配器的 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 Next
Const ALLOW_ALL = 0
strComputer = "."
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, arrPermittedIPProtocols
Next



EnableIPSec Method of the Win32_NetworkAdapterConfiguration Class:

uint32 EnableIPSec( 

string IPSecPermitTCPPorts[],  
string IPSecPermitUDPPorts[],  
string IPSecPermitIPProtocols[]
);
PowerShell & Scripts | 评论(0) | 引用(0) | 阅读(5237)
发表评论
昵称 [注册]
密码 游客无需密码
网址
电邮
打开HTML 打开UBB 打开表情 隐藏 记住我