You can run the following SQL query against your SMS database within SQL Management Studio
select v_FullCollectionMembership.CollectionID As 'Collection ID', v_Collection.Name As 'Collection Name', v_R_System.Name0 As 'Machine Name' from v_FullCollectionMembership
JOIN v_R_System on v_FullCollectionMembership.ResourceID = v_R_System.ResourceID
JOIN v_Collection on v_FullCollectionMembership.CollectionID = v_Collection.CollectionID
Where v_R_System.Name0='ClientMachineName'
Replace ClientMachineName with the device name
You can create a custom report within SCCM. You would need to modify the query slightly, you would replace the ClientMachineName section with a parameter, like so:
select v_FullCollectionMembership.CollectionID As 'Collection ID', v_Collection.Name As 'Collection Name', v_R_System.Name0 As 'Machine Name' from v_FullCollectionMembership
JOIN v_R_System on v_FullCollectionMembership.ResourceID = v_R_System.ResourceID
JOIN v_Collection on v_FullCollectionMembership.CollectionID = v_Collection.CollectionID
Where v_R_System.Name0=@Comp
I would encapsulate the above query into one dataset and use that to populate the table results within the report. Then create a second dataset holding the SQL query:
select Name0 from v_R_System
That can be used to populate the options within your @Comp parameter. Your SQL report builder will look something like this:
The above SQL should work both on Configuration Manager 2007 and Configuration Manager 2012.
No comments:
Post a Comment