imageHello, Lee Stevens again with a collection reporting tip…

So, here is a great little query that you can use to compare two tables for systems that happen to be in both collections.  In this query, we will be finding computer names, their joined domain (or workgroup), and the last known logged on user based on hardware inventory.  This was something that came up for me when I was comparing results of an OS Deployment, and needed to compare one collection of Windows XP machines against a more global collection of recently deployed Windows 7 machines.

In this query, we will be finding computer names, their joined domain (or workgroup), and the last known logged on user based on hardware inventory.

Here is the query you can use in SQL Management Studio:

select distinct c.name, d.UserName0, d.Domain0 from collectionmembers c
inner join Computer_System_DATA d on d.MachineID=c.MachineID
where c.MachineID in (select c.MachineID from CollectionMembers c where c.SiteID=('Insert Collection ID Here')
and c.machineid in (select c.MachineID from CollectionMembers c where c.SiteID=('Insert Collection ID Here')
order by Name

Something to note: You can use Name instead of MachineID to query 2 collections by name, instead of ID. This would be useful in the case of an OS Deployment where you say, start in Windows XP and end in Windows 7.

To add this as a custom ConfigMgr 2007 report, you will need to do 2 additional things:

1. It's recommended to add 2 prompts, I refer to them as @ID and @ID2. Simply change the following:

where c.MachineID in (select c.MachineID from CollectionMembers c where c.SiteID=('Insert Collection ID Here')
and c.machineid in (select c.MachineID from CollectionMembers c where c.SiteID=('Insert Collection ID Here')

To this:

where c.MachineID in (select c.MachineID from CollectionMembers c where c.SiteID=@ID)
and c.machineid in (select c.MachineID from CollectionMembers c where
c.SiteID=@ID2)

For more information on adding prompts to reports, consult the Config Manager Documentation.

2. You will need to change some permissions in the Config Manager Database.  You will need to grant the SELECT permission on the 2 mentioned tables to the webreport_approle Application Role. Otherwise, you will get a message like the following:

An error occurred when the report was run. The details are as follows:
SELECT permission denied on object '(object name)', database (database name)

Lee Stevens (Config Manager, OS Deployment) | Premier Field Engineer – Public Sector - Microsoft Corporation

App-V Team blog: http://blogs.technet.com/appv/
AVIcode Team blog: http://blogs.technet.com/b/avicode
ConfigMgr Support Team blog: http://blogs.technet.com/configurationmgr/
DPM Team blog: http://blogs.technet.com/dpm/
MED-V Team blog: http://blogs.technet.com/medv/
OOB Support Team blog: http://blogs.technet.com/oob/
Opalis Team blog: http://blogs.technet.com/opalis
Orchestrator Support Team blog: http://blogs.technet.com/b/orchestrator/
OpsMgr Support Team blog: http://blogs.technet.com/operationsmgr/
SCMDM Support Team blog: http://blogs.technet.com/mdm/
SCVMM Team blog: http://blogs.technet.com/scvmm
Server App-V Team blog: http://blogs.technet.com/b/serverappv
Service Manager Team blog: http://blogs.technet.com/b/servicemanager
System Center Essentials Team blog: http://blogs.technet.com/b/systemcenteressentials
WSUS Support Team blog: http://blogs.technet.com/sus/

clip_image001 clip_image002