Sometimes it is useful to script against SMS2003
Here is a sample of a function to query a collection and return any objects within that collection:
Function Get_Collection_Members(CollectionID)
'Connect to an SMS Provider, and get the SWbemServices object
Set objSWbemServices = GetObject("winmgmts:{impersonationLevel=impersonate}
!\\SERVER\root\sms\SITE_CODE")
'Exit if connection fails
If err.number<>0 Then
objOutputFile.Write "WBemServices connection failed"
wscript.quit
end If
'Get a collection of the desired SMS objects by using the
WBemServices.ExecQuery method. ExecQuery returns the collection as
'an SWbemObjectSet object. This example gets all resources that are
members of the passed variable "CollectionID"
set colCollection=objSWbemServices.ExecQuery
("SELECT * FROM SMS_FullCollectionMembership WHERE CollectionID='" & CollectionID & "'" )
'Read and echo out the SMS objects of that collection
for each objCollectionMember in colCollection
wscript.echo objCollectionMember.Name
Next
If colCollection.Count=0 Then
wscript.echo "no query results"
wscript.quit
End If
'Echo out total number of SMS objects in the collection
wscript.echo colCollection.count
End Function