Trying to automate the process of creating advertisements for the monthly MS
patches. The environment is SMS 2003.
It looks like I will need two separate scripts, or steps. The first is to
create the advertisement, then a separate step to create mandatory assignments
to the advertisement. The problem is that we create (2) mandatory
advertisements here. Until we did that we had an 85% success rate. Adding the
2nd assignment increased that to over 90%. I can get the script to create the
advertisement and the script to create a single assignment, but can’t get it to
create the 2nd assignment. It’s something I’m messing up with the array, but
I’m not sure what. Here is the script so far:
Dim objSWbemLocator
Dim objSWbemServices
Dim ProviderLoc
Dim AdvertisementID
Dim Location
Dim objAdvertisement
Dim i
Dim newST
Dim array()
Dim strSMSServer
strSMSServer = "SMS1"
AdvertisementID="GP12083A" 'Provide the required advertisement identifier here
'Connect to provider namespace for local computer.
Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")
Set objSWbemServices= objSWbemLocator.ConnectServer(strSMSServer, "root\sms")
Set ProviderLoc = objSWbemServices.InstancesOf("SMS_ProviderLocation")
For Each Location In ProviderLoc
If Location.ProviderForLocalSite = True Then
Set objSWbemServices = objSWbemLocator.ConnectServer _
(Location.Machine, "root\sms\site_" + Location.SiteCode)
End If
Next
Set objAdvertisement =
objSWbemServices.Get("SMS_Advertisement.AdvertisementID='" & AdvertisementID &
"'")
'Copy the current assigned schedule array to a local array that is one
'bigger than the current assigned schedule array.
redim array( UBound(objAdvertisement.AssignedSchedule)+1 )
For i=0 to UBound( objAdvertisement.assignedSchedule )
Set array(i) = objAdvertisement.AssignedSchedule(i)
Next
'Create an assignment.
Set newST = objSWbemServices.Get("SMS_ST_RecurInterval").SpawnInstance_()
newST.DayDuration=40
newST.DaySpan=50
'Add the new assignment to the end of the local array.
Set array( UBound(array) ) =newST
objAdvertisement.AssignedSchedule = array
objAdvertisement.Put_
Thanks,
Chris
~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/> ~