Adding Arrays

With Microsoft Internet Security and Acceleration (ISA) Server 2004 Enterprise Edition, you can create multiple ISA Server arrays in your enterprise. An array is an administrative unit for managing a group of ISA Server computers as a single, logical entity that can provide distributed caching, load balancing, and fault tolerance. Each ISA Server computer is associated with a single array, which holds configuration settings that are stored on a Configuration Storage server and are applied to all the ISA Server computers associated with it.

In the ISA Server hierarchy of administration COM objects, each array is represented by an FPCArray object, which is an element of the FPCArrays collection. This collection can be accessed through the Arrays property of the FPC root object

If you want to create a large number of arrays in your organization, you can accomplish this task efficiently using a script. This document provides two scripts for creating arrays that use the following techniques for obtaining the names of the arrays that will be created.

  • Combining a user-supplied prefix and a sequence number
  • Reading a list of array names stored in a text file

Both scripts can be run from an array member or a remote management computer.

Adding Arrays Using a Prefix

The Microsoft Visual Basic Scripting Edition (VBScript) code in AddArraysFromPrefix.vbs (listed later in this document) connects to the Configuration Storage server specified by the user using the credentials of a specified ISA Server administrator with read/write permissions for accessing the array configuration. Then the script tries to create the number of arrays requested by the user. The name of each array consists of a user-supplied prefix followed by a sequence number. If an array with a name generated in this way already exists, the attempt to create that array is aborted.

Usage:CScript AddArraysFromPrefix.vbs CSS UserName Domain Password Prefix NumberOfArrays

CSS specifies the name of a Configuration Storage server in the enterprise.

UserName specifies the user name of an ISA Server administrator with read/write permissions for accessing the array configuration.

Domain specifies the domain of the user specified in UserName.

Password specifies the password of the user specified in UserName.

Prefix specifies a string that will become the first part of the name of each array created.

NumberOfArrays specifies the number of arrays to create.

To create arrays using a prefix to generate the array names

  1. Create an instance of the FPC COM object, which is known as the root object and provides access to the other ISA Server administration COM objects.

  2. Declare an FPCArrays collection.

  3. Call the ConnectToConfigurationStorageServer method on the root object to connect to the Configuration Storage server specified by the user using the user name, domain name, and password provided by the user.

  4. Get a reference to the FPCArrays collection.

  5. In a While loop, create an array name from the prefix and the current value of the sequence number. Try to retrieve an array with the array name created from the arrays collection. If an array with the name created is not found in the arrays collection, call the Add method of the arrays collection to create it.

  6. Call the Save method of the arrays collection to write the configuration changes to storage.

Script Listing: AddArraysFromPrefix.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 connects to the Configuration Storage server specified by the

' user using the credentials of a specified ISA Server administrator with

' read/write permissions for accessing the array configuration. The script

' then creates new arrays with the names that consist of a user-supplied prefix

' followed by a sequence number.

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

Option Explicit

'Define the constant needed

Const Error_FileNotFound = &H80070002

Main(WScript.Arguments)

Sub Main(args)

If(args.Count <> 6) Then

Usage

End If

If IsNumeric(args(5)) = False Then

WScript.Echo "The Number argument must be numeric." & vbCrLf

Usage

End If

AddArrays args(0), args(1), args(2), args(3), args(4), CInt(args(5))

End Sub

Sub AddArrays(css, userName, domain, password, prefix, numberOfArrays)

' Create the root object.

Dim root ' The FPCLib.FPC root object

Set root = CreateObject("FPC.Root")

'Declare the other objects needed.

Dim isaArrays ' An FPCArrays collection

Dim arrayName ' A String

Dim i ' An Integer

' Connect to the Configuration Storage server.

On Error Resume Next

root.ConnectToConfigurationStorageServer css, userName, domain, password

CheckError

' Get a reference to the arrays collection.

Set isaArrays = root.Arrays

CheckError

i = 0

Do While i < numberOfArrays

i = i + 1

arrayName = prefix & CStr(i)

isaArrays.Item arrayName

If Err.Number = Error_FileNotFound Then

WScript.Echo "Creating the " & arrayName & " array..."

Err.Clear

isaArrays.Add arrayName

CheckError

End If

Loop

On Error GoTo 0

' Save the changes.

isaArrays.Save

WScript.Echo "Done!"

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 _

& " Cscript " & WScript.ScriptName & " CSS UserName Domain Password " _

& "Prefix NumberOfArrays" & VbCrLf _

& "" & VbCrLf _

& " CSS - Name of Configuration Storage server" & VbCrLf _

& " UserName - User name of an ISA Server administrator" & VbCrLf _

& " Domain - Domain of the user specified in UserName" & VbCrLf _

& " Password - Password of the user specified in UserName" & VbCrLf _

& " Prefix - Initial part of the array names" & VbCrLf _

& " NumberOfArrays - Number of arrays to create"

WScript.Quit

End Sub

Adding Arrays from a List

The VBScript code in AddArraysFromList.vbs (listed later in this document) connects to the Configuration Storage server specified by the user using the credentials of a specified ISA Server administrator with read/write permissions for accessing the array configuration. Then the script reads all the array names listed in a text file. If an array with a name listed in the file does not exist, a new array with that name is created.

Usage:CScript AddArraysFromList.vbs CSS UserName Domain Password FileName

CSS specifies the name of a Configuration Storage server in the enterprise.

UserName specifies the user name of an ISA Server administrator with read/write permissions for accessing the array configuration.

Domain specifies the domain of the user specified in UserName.

Password specifies the password of the user specified in UserName.

FileName specifies the name of a text file containing a list of array names.

To create arrays with the names listed in a text file

  1. Create an instance of the FPC COM object, which is known as the root object and provides access to the other ISA Server administration COM objects.

  2. Declare an FPCArrays collection.

  3. Call the ConnectToConfigurationStorageServer method on the root object to connect to the Configuration Storage server specified by the user using the user name, domain name, and password provided by the user.

  4. Get a reference to the FPCArrays collection.

  5. Create an instance of the FileSystemObject object, and call the OpenTextFile method on it to retrieve a TextStream object that represents the text file specified by the user.

  6. In a While loop, call the ReadLine method of the TextStream object to read each successive line in the text file. Try to retrieve an array with the array name on each line from the arrays collection. If an array is not found in the arrays collection, call the Add method of the arrays collection to create it.

  7. Call the Save method of the arrays collection to write the configuration changes to storage.

Script Listing: AddArraysFromList.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 connects to the Configuration Storage server specified by the

' user using the credentials of a specified ISA Server administrator with

' read/write permissions for accessing the array configuration. The script

' then creates new arrays with the names listed in a text file.

' Note that the text file must contain a list of array names with the name of

' each array 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 <> 5) Then

Usage

End If

AddArrays args(0), args(1), args(2), args(3), args(4)

End Sub

Sub AddArrays(css, userName, domain, password, fileName)

' Create the root object.

Dim root ' The FPCLib.FPC root object

Set root = CreateObject("FPC.Root")

'Declare the other objects needed.

Dim isaArrays ' An FPCArrays collection

Dim fso ' A FileSystemObject object

Dim fileStream ' A TextStream object

Dim textRead ' A String

Dim i ' An Integer

' Connect to the Configuration Storage server.

On Error Resume Next

root.ConnectToConfigurationStorageServer css, userName, domain, password

CheckError

' Get a reference to the arrays collection.

Set isaArrays = root.Arrays

CheckError

On Error GoTo 0

Set fso = CreateObject("Scripting.FileSystemObject")

Set fileStream = fso.OpenTextFile(fileName, ForReading)

Do While fileStream.AtEndOfStream <> True

textRead = fileStream.ReadLine

If textRead <> "" Then

On Error Resume Next

isaArrays.Item textRead

If Err.Number = Error_FileNotFound Then

WScript.Echo "Creating the " & textRead & " array..."

Err.Clear

isaArrays.Add textRead

CheckError

End If

End If

Loop

On Error GoTo 0

' Save the changes.

isaArrays.Save

WScript.Echo "Done!"

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 _

& " Cscript " & WScript.ScriptName & " CSS UserName Domain Password " _

& "FileName" & VbCrLf _

& "" & VbCrLf _

& " CSS - Name of Configuration Storage server" & VbCrLf _

& " UserName - User name of an ISA Server administrator" & VbCrLf _

& " Domain - Domain of the user specified in UserName" & VbCrLf _

& " Password - Password of the user specified in UserName" & VbCrLf _

& " FileName - Text file containing the list of arrays"

WScript.Quit

End Sub