TMG server ISA server 批量添加域名集

 ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

' Copyright (c) Microsoft Corporation. All rights reserved.

' THIS CODE IS MADE AVAILABLE AS IS, WITHOUT WARRANTY OF ANY KIND. THE ENTIRE

' RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS CODE REMAINS WITH THE

' USER. USE AND REDISTRIBUTION OF THIS CODE, WITH OR WITHOUT MODIFICATION, IS

' HEREBY PERMITTED.

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

' This script creates a new domain name set with the name specified by the user

' if it does not exist and imports all the domain names listed in a text file

' to the domain name set. If the specified domain name set already exists, the

' domain names in the text file are added without removing the existing domain

' names. In either case, duplicates are not added.

' This script has minimal error handling.

' Note that the text file must contain a list of domain names with each domain

' name on a separate line.

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Option Explicit

'Define the constants needed

Const Error_FileNotFound = &H80070002

Const ForReading = 1

Main(WScript.Arguments)

Sub Main(args)

If(args.Count <> 2) Then

Usage

End If

AddListToDomainNameSet args(0), args(1)

End Sub

Sub AddListToDomainNameSet(fileName, dnSetName)

' Create the root object.

Dim root ' The FPCLib.FPC root object

Set root = CreateObject("FPC.Root")

'Declare the other objects needed.

Dim isaArray ' An FPCArray object

Dim dnSets ' An FPCDomainNameSets collection

Dim dnSet ' An FPCDomainNameSet object

Dim fso ' A FileSystemObject object

Dim fileStream ' A TextStream object

Dim textRead ' A string

' Get references to the array object

' and the domain name sets collection.

Set isaArray = root.GetContainingArray()

Set dnSets = isaArray.RuleElements.DomainNameSets

' Retrieve the specified domain name set.

On Error Resume Next

Set dnSet = dnSets.Item(dnSetName)

If Err.Number = Error_FileNotFound Then

WScript.Echo "The " & dnSetName & "domain name set does not exist. " _

& "Creating it ..."

Set dnSet = dnSets.Add(dnSetName)

End If

On Error GoTo 0

Set fso = CreateObject("Scripting.FileSystemObject")

Set fileStream = fso.OpenTextFile(fileName, ForReading)

On Error Resume Next

Do While fileStream.AtEndOfStream <> True

textRead = fileStream.ReadLine

If textRead <> "" Then

Err.Clear

dnSet.Item textRead

If Err.Number = Error_FileNotFound Then

Err.Clear

WScript.Echo "Adding " & textRead

dnSet.Add textRead

End If

End If

Loop

On Error GoTo 0

' Save the changes.

dnSets.Save

WScript.Echo "Done!"

WScript.Quit

End Sub 

把以上代码存为VBS就可以了。使用方法 cmd下 cscript   *.vbs  文件名  域名集


文件为txt,格式如下


badiu.com

qq.com

...

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值