Partilhar via


How to Delete a Dashboard

Applies To: System Center Configuration Manager 2007, System Center Configuration Manager 2007 R2, System Center Configuration Manager 2007 R3, System Center Configuration Manager 2007 SP1, System Center Configuration Manager 2007 SP2

You delete a dashboard, in Microsoft System Center Configuration Manager 2007, by getting an existing instance of the SMS_ReportDashboard class and calling the delete method.

To delete a dashboard

  1. Set up a connection to the SMS Provider.

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

  3. Delete the dashboard by using the delete method.

Example

The following example method shows how to delete a dashboard by getting an existing instance of the SMS_ReportDashboard class and calling the delete method.

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

Sub DeleteDashboard(connection,          _
                    existingDashboardID)  

    ' Get an existing dashboard, identified by DashboardID, to delete. 
    Set existingDashboard = connection.Get("SMS_ReportDashboard.DashboardID=" & existingDashboardID)  
    
    ' Get the dashboard name for output.
    dashboardName = existingDashboard.Name
       
    ' Delete the dashboard.
    existingDashboard.Delete_
    
    ' Output a success message.
    Wscript.Echo "Deleted dashboard ID: "  & existingDashboardID
    Wscript.Echo "Dashboard name:       "  & dashboardName
                                   
End Sub
public void DeleteDashboard(WqlConnectionManager connection,
                            string existingDashboardID)
{
    try
    {
        // Get the specified dashboard instance (passed in as existingDashboardID).
        IResultObject dashboardToDelete = connection.GetInstance(@"SMS_ReportDashboard.DashboardID=" + existingDashboardID);

        // Delete the report instance.
        dashboardToDelete.Delete();

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

exisitingDashboardID

  • 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.

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

Concepts

System Center Configuration Manager Software Development Kit
Configuration Manager Reporting
SMS_ReportDashboard Server WMI Class