You modify a dashboard, in Microsoft System Center Configuration Manager 2007, by loading an existing instance of the SMS_ReportDashboard class, updating the properties, and saving the report.

To modify report properties

  1. Set up a connection to the SMS Provider.

  2. Load the existing report by using the SMS_ReportDashboard class and an existing dashboard ID.

  3. Update the property that needs to be modified.

  4. Save the dashboard and updated properties.

Example

The following example method shows how to modify a dashboard by loading an existing instance of the SMS_ReportDashboard class, updating the properties and saving the dashboard.

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

Visual Basic Script  Copy Code
Sub ModifyDashboard(connection, 	 _
					existingDashboardID,  _
					newDashboardComment) 

	' Get an existing dashboard, identified by existingDashboardID, to modify.
	Set existingDashboard = connection.Get("SMS_ReportDashboard.DashboardID=" & existingDashboardID)  

	' Replace the existing property value with the new property value.
	' In this example, the dashboard comment is replaced.
	existingDashboard.Comment = newDashboardComment
		 
	' Save the dashboard.
	existingDashboard.Put_

	' Output a success message.
	Wscript.Echo "Modified dashboard: " & existingDashboardID
								 
End Sub
C#  Copy Code
public void ModifyDashboard(WqlConnectionManager connection,
							string existingDashboardID,
							string newDashboardComment)
{
	try
	{
		// Get specific dashboard instance to modify.
		IResultObject dashboardToModify = connection.GetInstance(@"SMS_ReportDashboard.DashboardID=" + existingDashboardID);

		// Replace the existing report property with the new value (in this case the report comment).
		dashboardToModify["Comment"].StringValue = newDashboardComment;

		// Save dashboard and modified dashboard properties.
		dashboardToModify.Put();

		// Output dashboard ID.
		Console.WriteLine("Configured Dashboard ID: " + existingDashboardID);
}
	catch (SmsException ex)
	{
		Console.WriteLine("Failed to modify dashboard. 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.

existingDashboardID

  • Managed: Integer

  • VBScript: Integer

A value identifying the existing dashboard. In the code example, this value is passed as a string to simplify querying for the dashboard instance.

newDashboardComment

  • Managed: String

  • VBScript: String

A string with an updated property value. In the code example, the dashboard comment is updated.

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.