You list dashboards, in Microsoft System Center Configuration Manager 2007, by loading all instances of the SMS_ReportDashboard class and then enumerating the instances and output specific properties as required.

To list dashboards

  1. Set up a connection to the SMS Provider.

  2. Load all instances of the SMS_ReportDashboard class into a collection.

  3. Enumerate the collection of SMS_ReportDashboard instances and output any properties as required.

Example

The following example method shows how to list dashboards by loading all instances of the SMS_ReportDashboard class and then enumerating the instances and output specific properties as required.

For information about calling the sample code, see Calling Configuration Manager Code Snippets.

Visual Basic Script  Copy Code
Sub ListAllDashboards(connection)

' Build a query to get all dashboards. 
allDashboardQuery = "SELECT * FROM SMS_ReportDashboard"

' Run query to get a collection of all the dashboards.
Set allDashboards = connection.ExecQuery(allDashboardQuery, , wbemFlagForwardOnly Or wbemFlagReturnImmediately)

' Loop through collection of all dashboards to get the individual dashboard properties.
For Each dashboard in allDashboards

	' Output individual dashboard property details.
	wscript.echo "Dashboard Name:	"   & dashboard.Name
	wscript.echo "Dashboard ID:	"   & dashboard.DashboardID
	wscript.echo "Dashboard comment: "   & dashboard.Comment
	wscript.echo " "

Next

End Sub
C#  Copy Code
public void ListAllDashboards(WqlConnectionManager connection)
{
	try
	{
		// Get a collection of all SMS_ReportDashboard instances.
		IResultObject allDashboards = connection.QueryProcessor.ExecuteQuery("select * from SMS_ReportDashboard");

		// 
		foreach (IResultObject dashboard in allDashboards)
		{
			Console.WriteLine("Dashboard Name:	" + dashboard["Name"].StringValue);
			Console.WriteLine("Dashboard ID:	" + dashboard["DashboardID"].IntegerValue);
			Console.WriteLine("Dashboard comment: " + dashboard["Comment"].StringValue);
			Console.WriteLine(" ");
	}
}
	catch (SmsException ex)
	{
		Console.WriteLine("Failed to list dashboards. Error: " + ex.Message);
		throw;
}
}

The example method has the following parameters:

Parameter

Type

Description

Connection

  • Managed: WqlConnectionManager

  • VBScript: SWbemServices

A valid connection to the SMS Provider.

Compiling the Code

This C# example requires:

Namespaces

System

System.Collections.Generic

System.Text

Microsoft.ConfigurationManagement.ManagementProvider

Microsoft.ConfigurationManagement.ManagementProvider.WqlQueryEngine

Assembly

adminui.wqlqueryengine

microsoft.configurationmanagement.managementprovider

Robust Programming

For more information about error handling, see About Configuration Manager Errors.

Security

For more information about securing Configuration Manager applications, see Securing Configuration Manager Applications.

See Also


Send comments about this topic to Microsoft.