Export (0) Print
Expand All

Appendix B (Server Clusters: Remote Setup, Unattended Installations and Image-based Installations)

Updated: January 1, 2003

Applies To: Windows Server 2003 with SP1

CreateFS.vbs - Visual Basic script that creates a cluster file share 
Const ResourceType = "File Share" 
Const UsageString = "Usage: createfs cluster group resourcename path sharename <remarks> <sharesubdirs>" 
Const BasicArgs = 3 ' First three arguments will always be cluster, group, resourcename 
Const MinArgs = 5 ' BasicArgs + path + sharename 
Const MaxArgs = 7 ' BasicArgs + path + sharename + <remarks> + <sharesubdirs> 
'---------------------------------------------------------------------------- 
'Define the private properties we'll be working with in PrivArgNameArray 
' and define the default values in PrivArgArray 
'---------------------------------------------------------------------------- 
PrivArgNameArray = Array( "Path", "ShareName", "Remark", "ShareSubDirs" ) 
PrivArgArray = Array( "", "", "", 1 ) 
'---------------------------------------------------------------------------- 
' Define all of the resource types that we are dependent upon.  We'll only 
' add one of each type in the array, if present, and the first one we 
' encounter in our enumeration.  If none are found for one of the types 
' no errors are thrown.  It is up to the user to verify that everything 
' worked fine (e.g. path was to a shared disk we're dependent upon) 
'---------------------------------------------------------------------------- 
Const NumberOfDeps = 3 
DependencyArray = Array( "Physical Disk", "IP Address", "Network Name" ) 
Set oArgs = WScript.Arguments 
If oArgs.Count < MinArgs Or oArgs.Count > MaxArgs Then 
    '---------------------------------------------------------------------------- 
    'Usage 
    '---------------------------------------------------------------------------- 
    Wscript.Echo UsageString 
Else 
    '---------------------------------------------------------------------------- 
    'Parse the arguments 
    '---------------------------------------------------------------------------- 
    oClusterName = oArgs(0) 
    oGroupName = oArgs(1) 
    oResourceName = oArgs(2) 
    For iCounter = 0 To oArgs.Count - BasicArgs - 1 
        If True = IsNumeric( oArgs( iCounter + BasicArgs )) Then 
            PrivArgArray(iCounter) = CLng(oArgs(iCounter + BasicArgs)) 
        Else 
            PrivArgArray(iCounter) = oArgs(iCounter + BasicArgs) 
        End If 
    Next 
    '---------------------------------------------------------------------------- 
    'Open the Cluster 
    '---------------------------------------------------------------------------- 
    Set oCluster = CreateObject("MSCluster.Cluster") 
    oCluster.Open (oClusterName) 
    '---------------------------------------------------------------------------- 
    'Open the resgroup and add the new resource 
    '---------------------------------------------------------------------------- 
    Set oGroup = oCluster.ResourceGroups.Item(oGroupName) 
    Set oNewResource = oGroup.Resources.CreateItem(oResourceName, ResourceType, 0) 
    '---------------------------------------------------------------------------- 
    'Add any necessary dependencies 
    '---------------------------------------------------------------------------- 
    Set coldeps = oNewResource.Dependencies 
    For iCounter = 0 To NumberOfDeps - 1 
        For Each oResource In oGroup.Resources 
            If oResource.Type.Name = DependencyArray(iCounter) Then 
                coldeps.AddItem oResource 
                Exit For 
            End If 
        Next 
    Next 
    '---------------------------------------------------------------------------- 
    'Set the private properties for the new resource 
    '---------------------------------------------------------------------------- 
    Set colProperties = oNewResource.PrivateProperties 
    For iCounter = 0 To MaxArgs - BasicArgs - 1 
        colProperties.Item(PrivArgNameArray(iCounter)).Value = PrivArgArray(iCounter) 
    Next 
    colProperties.SaveChanges 
    '---------------------------------------------------------------------------- 
    'Cleanup 
    '---------------------------------------------------------------------------- 
    Set oCluster = Nothing 
    Set oGroup = Nothing 
    Set oResourceName = Nothing 
    Set iCounter = Nothing 
    Set oNewResource = Nothing 
    Set colProperties = Nothing 
    Set coldeps = Nothing 
End If 
'---------------------------------------------------------------------------- 
'Cleanup 
'---------------------------------------------------------------------------- 
Set oArgs = Nothing 
Set PrivArgArray = Nothing 
Set PrivArgNameArray = Nothing 
Set DependencyArray = Nothing
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft