Here is an update to my previous vbscript file that had collection listings.
This vbscript can be run from the console of SCCM. It will tell you what user a collection is in, what collection a computer is in. You also have the option of seeing if a maintenance window is set to the collection. This is my first version of this. Please let me know any changes
------------------compmain.vbs----------------------
'Matthew Hudson
'There is no warranty, run code at your own risk
''' sytanx: Application ResourceID Option
' option= blank No tag
' option=1 Collections with Maintenance windows will have a *
' option=2 Collections with Maintenance windows will have a description next to them
on error resume next
Dim CollectionArray(100)
Dim MainWindowArray(100)
count=0
Set objArgs = WScript.Arguments
if (objArgs.count > 1) then
Mainoption = wscript.arguments.item(1)
end if
ResourceID = wscript.arguments.item(0)
Set Shell = CreateObject("Wscript.Shell")
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set SWbemLocator=CreateObject("WbemScripting.SWbemLocator")
set SWbemServices = SWbemLocator.ConnectServer("SERVER","root\SMS\site_XXXX")
Set connection= swbemServices
strQuery = "select * from SMS_CollectionMember_a where ResourceID='"+ ResourceID +"'"
Set Collections = SWbemServices.ExecQuery(strQuery)
'''''''''''''''''' move through the collections
for each Collection in Collections
set Collectionfound=SWbemServices.Get("SMS_Collection='" & Collection.CollectionID & "'" )
CollectionArray(count)=Collectionfound.Name
'''''' see if there is a maintenance window
Set collectionSettingsInstance = SWbemServices.Get("SMS_CollectionSettings.CollectionID='" & Collection.CollectionID &"'" )
Set allCollectionSettings = connection.ExecQuery("Select * From SMS_CollectionSettings Where CollectionID = '" & Collection.CollectionID & "'")
If allCollectionSettings.Count > 0 then
MaintenanceWindowArray = collectionSettingsInstance.ServiceWindows
'wscript.echo Collectionfound.Name & len(MaintenanceWindowArray(0).Name)
if Mainoption="2" then
MainWindowArray(count)=MaintenanceWindowArray(0).Description
end if
if Mainoption="1" then
MainWindowArray(count)="*"
end if
end if
count=count+1
Next
'''''''''''''''
'Sort Collection list
for i = count - 2 To 0 Step -1
for j= 0 to i
if CollectionArray(j)>CollectionArray(j+1) then
temp=CollectionArray(j+1)
temp2=MainWindowArray(j+1)
CollectionArray(j+1)=CollectionArray(j)
MainWindowArray(j+1)=MainWindowArray(j)
CollectionArray(j)=temp
MainWindowArray(j)=temp2
end if
next
next
''' print out the collection listing
For NC = 0 to count-1
WhatCollections= WhatCollections & CollectionArray(NC) & " " & MainWindowArray(NC) & VbCrLf
Next
Wscript.echo WhatCollections
'''''''''''''''
'
-------------------------------------
<ActionDescription Class="Group" DisplayName="MCNS" MnemonicDisplayName="MCNS" Description="MCNS Tools" SqmDataPoint="100">
<ActionGroups>
<ActionDescription Class="Executable" DisplayName="Collection Listing" MnemonicDisplayName="Collection Listing" Description="Display machine Collection membership">
<Executable>
<FilePath>C:\Program Files\MCNS\collections\compmain.vbs</FilePath>
<Parameters>##SUB:ResourceID## 1</Parameters>
</Executable>
</ActionDescription>
</ActionGroups>
</ActionDescription>
If the tool vbscript just runs a black box and disappears then check out this link
http://sms-hints-tricks.blogspot.com/2008/05/vbscript-behavior.html