Sdílet prostřednictvím


Reporting Services WMI Provider

The Reporting Services WMI provider is built on standard Windows Management Instrumentation (WMI) technology for accessing control and management information in an enterprise environment. The WMI provider for Reporting Services serves as an instance provider, mapping the report server XML configuration elements to a set of classes, which include methods that you can call to add, remove, or modify report server configuration information. For more information about the classes, see Reporting Services WMI Provider Library.

WMI Provider Overview

WMI classes are included in Reporting Services to allow the report server and Report Manager components to be controlled on local and remote computers, to provide a way to discover which machines in the network that are running a Report Server Web service, and to activate a report server instance into a scale-out deployment. System administrators and database administrators can use these classes to make changes to the configurations of the report server and Report Manager after installation is complete, or to perform local or remote server administration tasks. Tasks include modifying the database connection credentials between the report server and the report server database, modifying the name of the report server database, and changing the URL that defines the installation path to the report server instance or Report Manager.

The classes installed to support these functions are as follows:

  • The MSReportServer_Instance Class provides basic information required for a client to connect to an installed report server.

  • The MSReportServer_ConfigurationSetting Class represents the installation and runtime parameters of a report server instance. These parameters are stored in the RSReportServer.config configuration file for the report server.

The namespace used to obtain information about Reporting Services in the code samples shown in this topic is the System.Management namespace, found in the Microsoft .NET Framework. The System.Management namespace provides a set of managed code classes through which .NET Framework applications can access and manipulate management information. For more information on using the Reporting Services WMI classes using the System.Management namespace, see "Accessing Management Information with System.Managment" in the Microsoft .NET Framework SDK.

Finding a Report Server Instance

If the computer has multiple instances of a report server installed, the administrator needs to point to the exact instance on the computer whose properties are being modified. To directly find the instance, each class contains a property that is defined as a key. This key property uniquely identifies a report server installation. The property defined as a key is the PathName property. The value of this property is the path to the RSReportServer.config configuration file, including the name of the configuration file. For most installations, this path would be similar to the following example:

C:\Program Files\Microsoft SQL Server\MSRS10.<InstanceName>\Reporting Services\ReportServer\rsreportserver.config

After the MSReportServer_ConfigurationSetting class is created, you can populate the key and search the computer for an instance of the report server or Report Manager that matches that key. If found, populate the management collection with the rest of the values from that instance.

You can also obtain information by populating a collection, and looping through the management class to display the information. If you are running this code from Visual Studio .NET, add a project reference to System.Management. The example below assumes that the RSReportServer.config configuration file is located in C:\Program Files\Microsoft SQL Server\MSRS10.<InstanceName>\Reporting Services\ReportServer\bin. The descriptions for the methods in the System.Management class can be found in the Microsoft Visual Studio .NET SDK.

The preferred way of finding information on your report server installations is to enumerate through the WMI instance collection. The example below shows how to find properties on every report server instance by creating a collection, and looping through the collection to display the properties.

Imports System
Imports System.Management
Imports System.IO

Module Module1
    Sub Main()
        Const WmiNamespace As String = "\\<ServerName>\root\Microsoft\SqlServer\ReportServer\<InstanceName>\v10\Admin"
        Const WmiRSClass As String = _
           "\\<ServerName>\root\Microsoft\SqlServer\ReportServer\<InstanceName>\v10\admin:MSReportServer_ConfigurationSetting"

        Dim serverClass As ManagementClass
        Dim scope As ManagementScope
        scope = New ManagementScope(WmiNamespace)
        'Connect to the Reporting Services namespace.
        scope.Connect()

        'Create the server class.
        serverClass = New ManagementClass(WmiRSClass)
        'Connect to the management object.
        serverClass.Get()
        If serverClass Is Nothing Then Throw New Exception("No class found")

        'Loop through the instances of the server class.
        Dim instances As ManagementObjectCollection = serverClass.GetInstances()
        Dim instance As ManagementObject
        For Each instance In instances
            Console.Out.WriteLine("Instance Detected")
            Dim instProps As PropertyDataCollection = instance.Properties
            Dim prop As PropertyData
            For Each prop In instProps
                Dim name As String = prop.Name
                Dim val As Object = prop.Value
                Console.Out.Write("Property Name: " + name)
                If val Is Nothing Then
                    Console.Out.WriteLine("     Value: <null>")
                Else
                    Console.Out.WriteLine("     Value: " + val.ToString())
                End If
            Next
        Next

        Console.WriteLine("--- Press any key ---")
        Console.ReadKey()


    End Sub
End Module
using System;
using System.Management;
using System.IO;
[assembly: CLSCompliant(true)]

class Class1
{
    [STAThread]
    static void Main(string[] args)
    {
        const string WmiNamespace = @"\\<ServerName>\root\Microsoft\SqlServer\ReportServer\<InstanceName>\v10\Admin";
        const string WmiRSClass =
          @"\\<ServerName>\root\Microsoft\SqlServer\ReportServer\<InstanceName>\v10\admin:MSReportServer_ConfigurationSetting";
        ManagementClass serverClass;
        ManagementScope scope;
        scope = new ManagementScope(WmiNamespace);

        // Connect to the Reporting Services namespace.
        scope.Connect();
        // Create the server class.
        serverClass = new ManagementClass(WmiRSClass);
        // Connect to the management object.
        serverClass.Get();
        if (serverClass == null)
            throw new Exception("No class found");

        // Loop through the instances of the server class.
        ManagementObjectCollection instances = serverClass.GetInstances();

        foreach (ManagementObject instance in instances)
        {
            Console.Out.WriteLine("Instance Detected");
            PropertyDataCollection instProps = instance.Properties;
            foreach (PropertyData prop in instProps)
            {
                string name = prop.Name;
                object val = prop.Value;
                Console.Out.Write("Property Name: " + name);
                if (val != null)
                    Console.Out.WriteLine("     Value: " + val.ToString());
                else
                    Console.Out.WriteLine("     Value: <null>");
            }
        }
        Console.WriteLine("\n--- Press any key ---");
        Console.ReadKey();
    }
}

For more information about the properties that can be read or changed on the report server and Report Manager, see Reporting Services WMI Provider Library. For more information on the properties specific to the report server, see MSReportServer_ConfigurationSetting Class. For information on the default installation of the configuration files, see Configuration Files (Reporting Services).