WMI query of reporting service instances returns all instances regardless of parent sql server path-Collection of common programming errors

We have some code to identify the SQL Server instances and their associated Reporting Server instances which is returning unexpected results.

A machine has two instances of SQL Express (2008) - (local)/SQLEXPRESS and (local)/EXPRESS_BOB – each with their own Reporting Server.

Using WMI, we identifiy the SQL Server instances and this works as expected. For each instance we then query for RS instances as follows:

public void QueryServers(string wmiPath)
{
    using (
        var searcher = new ManagementObjectSearcher(
           wmiPath, 
           "Select * from MSReportServer_ConfigurationSetting"))
    {
        ManagementObjectCollection moc = searcher.Get();
        //
        // Process objects in moc
        //
    }
}

This is run for two values of wmiPath (note – requires Run as Admin):

  • wmiPath = “root\Microsoft\SqlServer\ReportServer\RS_SQLEXPRESS\v10\Admin”
  • wmiPath = “root\Microsoft\SqlServer\ReportServer\RS_EXPRESS_5fBOB\v10\Admin”

Regardless of the value of wmiPath, the moc collection always holds two values:

  • moc[0] [“InstanceName”] = “SQLEXPRESS”
  • moc[1] [“InstanceName”] = “EXPRESS_BOB”

How is it that a query under a specified SQL Server instances’ WMI path returns Report Server instances that (I expect to) live under a different path?

Is this the correct path to be querying?