다음을 통해 공유


How to Modify Report Properties

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 modify a report, in Microsoft System Center Configuration Manager 2007, by loading an existing instance of the SMS_Report 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_Report class and an existing report ID.

  3. Update the property that needs to be modified.

  4. Save the report and updated properties.

Example

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

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

Sub ModifyReport(connection,        _
                 existingReportID,  _
                 newReportComment)                         

    ' Get an existing report, identified by ReportID, to modify.
    Set existingReport = connection.Get("SMS_Report.ReportID=" & existingReportID)  
    
    ' Get report name for output.
    existingReport.Comment = newReportComment
           
    ' Delete the report.
    existingReport.Put_
    
    ' Output a success message.
    Wscript.Echo "Modified report: " & existingReportID
                                   
End Sub
public void ModifyReport(WqlConnectionManager connection, 
                         string existingReportID,
                         string newReportComment)
{
    try
    {
        // Get specific report instance to modify.
        // The existingReportID is passed as a string to facilitate building the query.
        IResultObject reportToModify = connection.GetInstance(@"SMS_Report.ReportID=" + existingReportID);

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

        // Save report and modified report properties.
        reportToModify.Put();

        // Output report ID and report name.
        Console.WriteLine("Configured Report ID: " + reportToModify["ReportID"].StringValue);
    }
    catch (SmsException ex)
    {
        Console.WriteLine("Failed to modify report. 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.

existingReportID

  • Managed: Integer

  • VBScript: Integer

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

newReportComment

  • Managed: String

  • VBScript: String

A string with an updated property value. In the code example, the report 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

Concepts

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