This script creates site boundaries from the proparray values within the script. Any number of boundaries can be created when you add additional proparray values. Valid site boundary types include IP subnet and Active Directory site.


Dim objSWbemLocator
Dim objSWbemServices
Dim objSWbemContext
Dim objSWbemInst
Dim proparray1
Dim proparray2
Dim Sitecode
Dim inputArray1(2)
Dim inputArray2(2)
Dim i
Dim bounds

'Add boundaries to this array as you need them.
inputArray2(0)="IP Subnet"

inputArray1(1)="TEST 1 SITE"
inputArray2(1)="Active Directory site"

Set objSWbemLocator =  CreateObject("WbemScripting.SWbemLocator")
Set objSWbemServices = objSWbemLocator.ConnectServer( , "root\sms\site_" & sitecode )

Set objSWbemContext=CreateObject("WbemScripting.SWbemNamedValueSet")
objSWbemContext.Add "SessionHandle", objSWbemServices.ExecMethod("SMS_SiteControlFile", "GetSessionHandle").SessionHandle
objSWbemServices.ExecMethod "SMS_SiteControlFile.Filetype=1,Sitecode='" & Sitecode & "'", "RefreshSCF", , , objSWbemContext
Set objSWbemInst = objSWbemServices.Get("SMS_SCI_SiteAssignment.Filetype=2,Itemtype='Site Assignment',Sitecode='" & Sitecode & "',ItemName='Site Assignment'", , objSWbemContext)

'Retrieve the boundary details.
proparray1 = objSWbemInst.AssignDetails
proparray2 = objSWbemInst.AssignTypes

if ubound(objSWbemInst.AssignDetails)=-1 then 'There are no boundaries so create an array.
redim proparray1(1)
redim proparray2(1)
	bounds=ubound (objSWbemInst.AssignDetails)+1 'Increase array for new boundaries
	ReDim Preserve proparray1 (ubound (proparray1) + ubound (inputArray1))
	ReDim Preserve proparray2 (ubound (proparray2) + ubound (inputArray2))
End If

for i= 0 to ubound(inputArray1)-1 'Add boundaries

objSWbemInst.AssignDetails = proparray1
objSWbemInst.AssignTypes = proparray2
objSWbemInst.Put_ , objSWbemContext

objSWbemServices.ExecMethod "SMS_SiteControlFile.Filetype=0,Sitecode=""" & Sitecode & """", "Commit", , , objSWbemContext
objSWbemServices.Get("SMS_SiteControlFile").ReleaseSessionHandle objSWbemContext.Item("SessionHandle").Value

Compiling the Code

  • Requires Windows 2000 Server SP2 or later.

  • Requires an SMS 2003 Site Server.

See Also