• 企业400电话
  • 微网小程序
  • AI电话机器人
  • 电商代运营
  • 全 部 栏 目

    企业400电话 网络优化推广 AI电话机器人 呼叫中心 网站建设 商标✡知产 微网小程序 电商运营 彩铃•短信 增值拓展业务
    VBScript使用ADSI为IIS批量添加屏蔽或允许访问的IP

    复制代码 代码如下:

    '/*=========================================================================
    ' * Intro VBScript使用ADSI为IIS批量添加屏蔽或允许访问的IP
    ' * FileName VBScript-ADSI-IIS-Add-Deny-Grant-IP-Change-MetaBase.xml.vbs
    ' *==========================================================================*/
    'AddDenyIP2All "192.168.1.106,255.255.255.0"
    'AddDenyIP2All "127.0.0.1"
    'AddDenyIP "123456","127.0.0.1"
    '添加要屏蔽的IP或一组计算机,到一个指定站点上
    Sub AddDenyIP(strWebNo, strDenyIp)
    On Error Resume Next
    Set SecObj = GetObject("IIS://LocalHost/W3SVC/" strWebNo "/Root")
    Set MyIPSec = SecObj.IPSecurity
    MyIPSec.GrantByDefault = True
    IPList = MyIPSec.IPDeny
    i = UBound(IPList) + 1
    ReDim Preserve IPList(i)
    IPList(i) = strDenyIp
    MyIPSec.IPDeny = IPList
    SecObj.IPSecurity = MyIPSec
    SecObj.Setinfo
    End Sub
    '添加要屏蔽的IP或一组计算机,到IIS公共配置,以应用到所有站点
    '如果之前对有些站点单独做过屏蔽IP设置,在些设置不会生效,得在总的网站上设置一下,然后覆盖所有子结点
    Sub AddDenyIP2All(strDenyIp)
    On Error Resume Next
    Set SecObj = GetObject("IIS://LocalHost/W3SVC")
    Set MyIPSec = SecObj.IPSecurity
    MyIPSec.GrantByDefault = True
    IPList = MyIPSec.IPDeny
    i = UBound(IPList) + 1
    ReDim Preserve IPList(i)
    IPList(i) = strDenyIp
    MyIPSec.IPDeny = IPList
    SecObj.IPSecurity = MyIPSec
    SecObj.Setinfo
    End Sub
    '添加允许的IP或一组计算机,到一个指定站点上
    Sub AddGrantIP(strWebNo, strGrantIp)
    On Error Resume Next
    Set SecObj = GetObject("IIS://LocalHost/W3SVC/" strWebNo "/Root")
    Set MyIPSec = SecObj.IPSecurity
    MyIPSec.GrantByDefault = False
    IPList = MyIPSec.IPGrant
    i = UBound(IPList) + 1
    ReDim Preserve IPList(i)
    IPList(i) = strGrantIp
    MyIPSec.IPGrant = IPList
    SecObj.IPSecurity = MyIPSec
    SecObj.Setinfo
    End Sub
    '添加允许的IP或一组计算机,到IIS公共配置,以应用到所有站点
    '如果之前对有些站点单独做过屏蔽IP设置,在些设置不会生效,得在总的网站上设置一下,然后覆盖所有子结点
    Sub AddGrantIP2All(strGrantIp)
    On Error Resume Next
    Set SecObj = GetObject("IIS://LocalHost/W3SVC")
    Set MyIPSec = SecObj.IPSecurity
    MyIPSec.GrantByDefault = False
    IPList = MyIPSec.IPGrant
    i = UBound(IPList) + 1
    ReDim Preserve IPList(i)
    IPList(i) = strGrantIp
    MyIPSec.IPGrant = IPList
    SecObj.IPSecurity = MyIPSec
    SecObj.Setinfo
    End Sub
    '显示IIS公共配置里禁止访问的IP
    Sub ListDenyIP()
    Set SecObj = GetObject("IIS://LocalHost/W3SVC")
    Set MyIPSec = SecObj.IPSecurity
    IPList = MyIPSec.IPDeny 'IPGrant/IPDeny
    WScript.Echo Join(IPList, vbCrLf)
    ' For i = 0 To UBound(IPList)
    ' WScript.Echo i + 1 "-->" IPList(i)
    ' Next
    End Sub

    上一篇:可以查询系统用户名sid的vbs
    下一篇:WMI IE代理 切换或改变(Use WMI Change IE Proxy)
  • 相关文章
  • 

    © 2016-2020 巨人网络通讯 版权所有

    《增值电信业务经营许可证》 苏ICP备15040257号-8

    VBScript使用ADSI为IIS批量添加屏蔽或允许访问的IP VBScript,使用,ADSI,为,IIS,批量,