ShowBasicInfo1.vbs


The first script shows some basic information about ISA Server 2004. It is not a complex script, but illustrates some basic coding techniques, including connecting to your ISA server using the COM, along with some basic VBScript functions.

To create an empty VBScript file, follow these steps:

  1. Start your script editing program.

  2. Create a new file.

  3. Set the configuration to use VBScript.

You now have an empty VBScript file. Always start your script by noting information on the script's purpose, any prerequisites or requirements, and the version number. When writing comments in a script you should use a single quote (') as the first character in each line, as shown here:

 '==================================================================== ' PURPOSE: Shows Basic ISA Server 2004 Information ' ' NAME: ShowBasicInfo1.vbs ' ' RUN: cscript ShowBasicInfo1.vbs ' ' WHERE: Run on an ISA Server 2004, Local on Server ' ' COMMENT: This script was written by Jesper Hanno Hansen. ' ' VERSION: 1.0 '==================================================================== 

Then the coding can begin. Declare the variable objRoot and set it to the root of the ISA administration object hierarchy, which provides access to all the configuration of the ISA arrays.

Best Practices 

Add comments to your script to clarify the meaning of each section of code. Comments are not executed and are preceded by a single quote.

Your code should look like the following example:

 ' Declare the variable objRoot Dim objRoot ' Create an objRoot Object to ISA Server 2004 and set it as objRoot Set objRoot = CreateObject("FPC.Root") 

If you are using the PrimalScript editor, when you type a "dot" after objRoot you will see that it exposes the properties and methods the object model offers. Figure 12-1 illustrates this handy function.

image from book
Figure 12-1: One of the advanced functions of PrimalScript is that it provides the object model in a drop-down menu to speed scripting functions.

Note 

For a detailed explanation of the methods and properties to which the root object gives access, see the ISA Server 2004 SDK.

To open the ISA Server 2004 SDK, follow these steps:

  1. Open the Run command.

  2. Type the path to your ISA Server SDK help file. By default, the SDK is stored at C:\Program Files\Microsoft ISA 2004 SDK\Help\Isasdk.chm.

  3. Click OK.

To see the properties of the FPC.Root object, navigate to the correct location in the Isasdk.chm file by performing the following steps:

  1. Expand Administration COM Documentation.

  2. Expand Microsoft Internet Security and Acceleration Server 2004.

  3. Expand Administration Reference.

  4. Expand COM Objects.

  5. Select FPC.

The FPC object provides access to two methods and one property that can be used in ISA Server 2004 Standard Edition, which are shown in Table 12-3.

Table 12-3: FPC Root Object

Type

Name

Description

Method

GetContainingArray

Retrieves the FPCArray Object

Method

GetContainingServer

Retrieves the FPCServer Object

Property

Arrays

An FPCArrays Collection

In this script we want to expose basic information from ISA Server 2004 itself, which requires us to create a reference to the FPCServer object, as it contains the relevant information. To create a reference to the FPCServer object, type the following lines in the script:

 ' Create an FPCServer Object from the current ISA Server 2004 ' this Object gives access to the Properties we want to use. Dim objFPCServer Set objFPCServer = objRoot.GetContainingServer 

In the SDK, click on the FPCServer to the GetContainingServer in the Method table as shown in Figure 12-2.

image from book
Figure 12-2: The GetContainingServer Method entry in the SDK provides detailed information regarding the properties and usage of the method.

This shows the methods and properties to which the FPCServer object provides access. Your script could show any of the properties listed under the Properties section in the SDK, such as the following:

  • CreatedTime (Date)

  • FQDN (String)

  • Name (String)

  • ProductVersion (String)

To see the property value—and other valuable information—click the name of the property. For example, the Name property is a string value and it is read only. To continue our example, type the following lines of code in the script:

 ' Set the dtmCreatedTime to the value of FPCServer.CreatedTime Dim dtmCreate dTimedtmCreatedTime = objFPCServer.CreatedTime ' Set the strFQDN to the value of FPCServer.FQDN Dim strFQDN strFQDN = objFPCServer.FQDN ' Set the strName to the value of FPCServer.Name Dim strName strName = objFPCServer.Name ' Set the strProductVersion to the value of FPCServer.ProductVersion Dim strProductVersion strProductVersion = objFPCServer.ProductVersion 

The script is almost complete, but to see the values we need some lines to write out the data captured in the variables. To export the data, type the following lines in the script:

 'The Wscript.Echo is a VBScript function that writes data to the screen WScript.Echo "CreatedTime         " & dtmCreatedTime WScript.Echo "FQDN                " & strFQDN WScript.Echo "Name                " & strName WScript.Echo "ProductVersion      " & strProductVersion 

Now that we completed the individual parts of the script, let's take a look at the final, complete script:

 '==================================================================== ' ' PURPOSE: Shows Basic Information on ISA Server 2004 ' ' NAME: ShowBasicInfo1.vbs ' ' RUN: cscript ShowBasicInfo1.vbs ' ' WHERE: Run on an ISA Server 2004, Local on Server ' ' COMMENT: This script was written by Jesper Hanno Hansen. ' ' VERSION: 1.0' ' ===================================================================== ' Create a Root Object to ISA Server 2004 Dim objRoot Set objRoot = CreateObject("FPC.Root") ' Create an FPCServer Object from the current ISA Server 2004 ' this Object gives access to the Properties we want to use. Dim objFPCServer Set objFPCServer = objRoot.GetContainingServer ' Set the dtmCreatedTime to the value of FPCServer.CreatedTime Dim dtmCreatedTime dtmCreatedTime = objFPCServer.CreatedTime ' Set the strFQDN to the value of FPCServer.FQDN Dim strFQDN strFQDN = objFPCServer.FQDN ' Set the strName to the value of FPCServer.Name Dim strName strName = objFPCServer.Name ' Set the strProductVersion to the value of FPCServer.ProductVersion Dim strProductVersion strProductVersion = objFPCServer.ProductVersion ' Using Wscript.Echo to write information to the screen WScript.Echo "CreatedTime         " & dtmCreatedTime WScript.Echo "FQDN                " & strFQDN WScript.Echo "Name                " & strName WScript.Echo "ProductVersion      " & strProductVersion 

Save the script as C:\ISAScripts\ShowBasicInfo1.vbs and run the script by typing cscript C:\IsaScripts\showbasicinfo1.vbs at a command prompt, or use the appropriate Run command from your script editor (like F7 with PrimalScript).

Note 

You should now have some basic skills in scripting with ISA Server 2004. The next examples contain less detail and focus more on the scripts themselves.




Microsoft Internet Security and Acceleration ISA Server 2004 Administrator's Pocket Consultant
Microsoft Internet Security and Acceleration (ISA) Server 2004 Administrators Pocket Consultant (Pro-Administrators Pocket Consultant)
ISBN: 0735621888
EAN: 2147483647
Year: 2006
Pages: 173

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net