在 ISA Server 2004中,可以通过检索代表策略规则的对象的属性来创建包含策略规则信息的报告。PolicyRulesReport.vbs 中的 Microsoft Visual Basic Scripting Edition (VBScript) 代码可以检索系统策略规则集合和策略规则集合,循环访问这些集合,并生成一个报告。
该报告中将包含规则名称,并将指示出各个规则是否已启用。可以修改此脚本以生成一些包含这些规则的其他属性的报告。
用法:
Cscript PolicyRulesReport.vbs(或双击执行)
创建一个策略规则报告
1.创建一个 FPC COM 对象实例,此实例提供对其他 ISA 服务器管理 COM 对象的访问。
2.声明一个 FPCArray 对象﹑两个 FPCPolicyRules 集合和一个 FPCPolicyRule 对象。
3.获取对现有的 FPCArray 对象﹑系统策略规则的 FPCPolicyRules 集合和普通策略规则的FPCPolicyRules 集合的引用。
4.在一个 For 循环中,循环访问系统策略规则集合中的对象。对每个系统策略规则,检索Enabled属性的值并显示规则的名称,名称后紧跟一个表明此规则被启用还是被禁用的指示符。
5.在一个 For 循环中,循环访问策略规则集合中的对象。对每个策略规则,检索 Enabled属性的值并显示规则的名称,名称后紧跟一个表明此规则被启用还是被禁用的指示符。
PolicyRulesReport.vbs的内容如下,复制到记事本中另存为vbs扩展名即可:
=================================================================================
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' 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 retrieves the collection of system policy rules and the
' collection of policy rules and implicitly uses the _NewEnum property to
' iterate through the collections and display the names of the rules with
' an indication of whether each rule is enabled.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub IteratePolicyRules()
' Create the root obect.
Set root = CreateObject("FPC.Root")
' Declare the other objects needed.
Dim array ' An FPCArray object
Dim spRules ' An FPCPolicyRules collection
Dim rules ' An FPCPolicyRules collection
Dim rule ' An FPCPolicyRule object
Dim isEnabled ' A string
' Get references to the array object, the system
' policy rules collection, and the policy rules collection.
Set array = root.GetContainingArray()
Set spRules = array.SystemPolicy.PolicyRules
Set rules = array.ArrayPolicy.PolicyRules
' List the system policy rules and indicate whether each
' rule is enabled.
WScript.Echo "***System Policy Rules***"
For Each rule In spRules
If rule.Enabled = True Then
isEnabled = "Enabled"
Else
isEnabled = "Disabled"
End If
WScript.Echo rule.Name & ": " & isEnabled
Next
' List the policy rules and indicate whether each
' rule is enabled.
WScript.Echo vbCrLf & "***Policy Rules***"
For Each rule In rules
If rule.Enabled = True Then
isEnabled = "Enabled"
Else
isEnabled = "Disabled"
End If
WScript.Echo rule.Name & ": " & isEnabled
Next
End Sub
IteratePolicyRules