Right Click Tools - Collection Listing
Main Menu
>
Tools
>
Right Click Tools
Collection Listing
Right click on a computer or user and see what collection that resource is in as well as what maintanence window is associated with it.
Download
Code
------------------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 --------------------------------------
Documentation
You will need to create a Action folder and an XML file. You may also edit a pre-existing XML file X:\Program Files\Microsoft Configuration Manager\AdminUI\XmlStorage\Extensions\Actions\7ba8bf44-2344-4035-bdb4-16630291dcf6\Tools.xml The XML tool will need to be between the:
C:\Program Files\MCNS\collections\compmain.vbs
##SUB:ResourceID## 1
If you see a black box and then disappears then you need to reset your wscript settings: Set the default method for vbscript to wscript. Run the following line on a command prompt window: wscript /H:WScript --Created by: Matthew Hudson