{"id":7304,"date":"2014-06-07T02:23:37","date_gmt":"2014-06-07T02:23:37","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/06\/07\/wmi-query-of-reporting-service-instances-returns-all-instances-regardless-of-parent-sql-server-path-collection-of-common-programming-errors\/"},"modified":"2014-06-07T02:23:37","modified_gmt":"2014-06-07T02:23:37","slug":"wmi-query-of-reporting-service-instances-returns-all-instances-regardless-of-parent-sql-server-path-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/06\/07\/wmi-query-of-reporting-service-instances-returns-all-instances-regardless-of-parent-sql-server-path-collection-of-common-programming-errors\/","title":{"rendered":"WMI query of reporting service instances returns all instances regardless of parent sql server path-Collection of common programming errors"},"content":{"rendered":"<p>We have some code to identify the SQL Server instances and their associated Reporting Server instances which is returning unexpected results.<\/p>\n<p>A machine has two instances of <code>SQL Express (2008) - (local)\/SQLEXPRESS<\/code> and <code>(local)\/EXPRESS_BOB<\/code> &#8211; each with their own Reporting Server.<\/p>\n<p>Using WMI, we identifiy the SQL Server instances and this works as expected. For each instance we then query for RS instances as follows:<\/p>\n<pre><code>public void QueryServers(string wmiPath)\n{\n    using (\n        var searcher = new ManagementObjectSearcher(\n           wmiPath, \n           \"Select * from MSReportServer_ConfigurationSetting\"))\n    {\n        ManagementObjectCollection moc = searcher.Get();\n        \/\/\n        \/\/ Process objects in moc\n        \/\/\n    }\n}\n<\/code><\/pre>\n<p>This is run for two values of wmiPath (note &#8211; requires Run as Admin):<\/p>\n<blockquote>\n<ul>\n<li>wmiPath = &#8220;root\\Microsoft\\SqlServer\\ReportServer\\RS_SQLEXPRESS\\v10\\Admin&#8221;<\/li>\n<li>wmiPath = &#8220;root\\Microsoft\\SqlServer\\ReportServer\\RS_EXPRESS_5fBOB\\v10\\Admin&#8221;<\/li>\n<\/ul>\n<\/blockquote>\n<p>Regardless of the value of <code>wmiPath<\/code>, the <code>moc<\/code> collection always holds <em>two<\/em> values:<\/p>\n<blockquote>\n<ul>\n<li><em>moc[0]<\/em> [&#8220;InstanceName&#8221;] = &#8220;SQLEXPRESS&#8221;<\/li>\n<li><em>moc[1]<\/em> [&#8220;InstanceName&#8221;] = &#8220;EXPRESS_BOB&#8221;<\/li>\n<\/ul>\n<\/blockquote>\n<p>How is it that a query under a specified SQL Server instances&#8217; WMI path returns Report Server instances that (I expect to) live under a different path?<\/p>\n<p>Is this the correct path to be querying?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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) &#8211; (local)\/SQLEXPRESS and (local)\/EXPRESS_BOB &#8211; each with their own Reporting Server. Using WMI, we identifiy the SQL Server instances and this works as expected. For [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-7304","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7304","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=7304"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7304\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=7304"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=7304"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=7304"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}