''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' 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 changes the additional key of the specified alert (for example,
' the "Cached object discarded" alert) from 0 to -1, if necessary, on a
' computer running ISA Server 2004 Standard Edition, or in all arrays of the
' enterprise for computers running ISA Server 2004 Enterprise Edition.
' The script can be run on an ISA Server computer with the Firewall service
' installed, a remote management computer, or a Configuration Storage server
' (Enterprise Edition). If the script needs to connect to an ISA Server
' computer with the Firewall service installed or to a Configuration Storage
' server, it prompts the user for the name of the applicable computer and uses
' the credentials of the user who is logged on to connect to it.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Option Explicit
' Define the constants needed.
Const additionalKey = -1
Const Error_NotConnectedToCSS = &HC00403A6
Const Error_ConfigurationStorageServer = &HC00403A0
Const fpcTypeStandardEdition = 0
Main(WScript.Arguments)
Sub Main(args)
' Declare the objects needed.
Dim root ' The FPCLib.FPC root object
Dim isaArray ' An FPCArray object
Dim serverName ' A String
Dim num ' An Integer
If (args.Count <> 1) Then
Usage()
End If
' Create the root object.
Set root = CreateObject("FPC.Root")
' Try to get the number of arrays.
On Error Resume Next
num = root.Arrays.Count
If Err.Number = Error_NotConnectedToCSS Then
serverName = _
InputBox("Enter the name of a Configuration Storage server.")
' Connect to the specified Configuration Storage server.
Err.Clear
root.ConnectToConfigurationStorageServer serverName
CheckError
ChangeAlertAdditionalKeyEE root, args(0)
ElseIf num = 0 Then
serverName = ""
Set isaArray = root.Arrays.Connect(serverName)
If Err.Number = Error_ConfigurationStorageServer Then
WScript.Echo "No arrays are configured in the enterprise."
WScript.Quit
End If
Err.Clear
' Get the name of an ISA Server computer with the Firewall service
' installed.
serverName _
= InputBox("Enter the name of an ISA Server computer.")
Err.Clear
Set isaArray = root.Arrays.Connect(serverName)
If Err.Number = 0 Then
ChangeAlertAdditionalKeySE isaArray, args(0)
Else
WScript.Echo "The specified computer is not available " _
& "or does not have the Firewall service installed."
WScript.Quit
End If
Else
Set isaArray = root.Arrays.Item(1)
CheckError
If isaArray.Type = fpcTypeStandardEdition Then
ChangeAlertAdditionalKeySE isaArray, args(0)
Else
ChangeAlertAdditionalKeyEE root, args(0)
End If
End If
End Sub
Sub ChangeAlertAdditionalKeyEE(root, alertName)
' Declare the objects needed.
Dim isaArrays ' An FPCArrays collection
Dim isaArray ' An FPCArray object
Dim alert ' An FPCAlert object
Dim eventGUID ' A String
' Get a reference to the arrays collection.
Set isaArrays = root.Arrays
On Error Resume Next
For Each isaArray In isaArrays
' Get a reference to the alert object
Set alert = isaArray.Alerts(alertName)
If Err.Number = 0 Then
WScript.Echo "The current additional key is " _
& alert.AdditionalKey & "."
' Change the additional key if it is equal to 0.
If alert.AdditionalKey = 0 Then
WScript.echo "Changing the additional key to " _
& additionalKey & " in the " & isaArray.Name & " array..."
alert.SetDefinitions alert.EventGuid, , additionalKey
CheckError
alert.Save
CheckError
End If
Else
WScript.Echo "The " & alertName & " alert was not found in " _
& isaArray.Name & "."
Err.Clear
End If
Next
End Sub
Sub ChangeAlertAdditionalKeySE(isaArray, alertName)
' Declare the objects needed.
Dim alert ' An FPCAlert object
Dim eventGUID ' A String
' Get a reference to the alert object
On Error Resume Next
Set alert = isaArray.Alerts(alertName)
If Err.Number = 0 Then
WScript.Echo "The current additional key is " _
& alert.AdditionalKey & "."
' Change the additional key if it is equal to 0.
If alert.AdditionalKey = 0 Then
WScript.echo "Changing the additional key to " _
& additionalKey & "..."
alert.SetDefinitions alert.EventGuid, , additionalKey
CheckError
alert.Save
CheckError
End If
Else
WScript.Echo "The " & alertName & " alert was not found."
Err.Clear
End If
End Sub
Sub CheckError()
If Err.Number <> 0 Then
WScript.Echo "An error occurred: 0x" & Hex(Err.Number) & ". " _
& Err.Description
Err.Clear
WScript.Quit
End If
End Sub
Sub Usage()
WScript.Echo "Usage:" & VbCrLf _
& " " & WScript.ScriptName & " AlertName" & VbCrLf _
& "" & VbCrLf _
& " AlertName - Alert whose additional key is to be changed"
WScript.Quit
End Sub