다음을 통해 공유


배포 패키지에 업데이트 추가하는 방법

Configuration Manager SMS_SoftwareUpdatesPackage 클래스의 인스턴스를 가져오고 AddUpdateContent 메서드를 사용하여 소프트웨어 업데이트 배포 패키지에 업데이트를 추가합니다.

소프트웨어 업데이트 배포 패키지를 만들려면

  1. SMS 공급자에 대한 연결을 설정합니다.

  2. 클래스를 사용하여 기존 패키지 개체를 SMS_SoftwareUpdatesPackage 가져옵니다.

  3. 메서드를 사용하여 기존 패키지에 업데이트 콘텐츠를 추가합니다 AddUpdateContent .

예시

다음 예제 메서드는 클래스 및 AddUpdateContent 메서드를 사용하여 SMS_SoftwareUpdatesPackage 소프트웨어 업데이트 배포 패키지에 업데이트를 추가하는 방법을 보여 줍니다.

참고

업데이트는 C#의 사전 개체 addUpdateContentParameters 의 일부로 콘텐츠 원본 경로에서 사용할 수 있어야 합니다. 패키지 원본에 업데이트가 있는 경우 해당 패키지 원본을 둘 이상의 배포 패키지에 사용할 수 없습니다.

중요

메서드가 실패 시 메서드 호출에서 반환되지 않으므로 VBScript 예제가 포함되지 AddUpdateContent 않았습니다. 이는 알려진 문제이며 조사 중입니다.

샘플 코드 호출에 대한 자세한 내용은 코드 조각 Configuration Manager 호출을 참조하세요.

C#의 메서드 호출 예:

// PREWORK FOR AddUpdatesToSUMDeploymentPackage  

// Define the array of Content Ids to load into addUpdateContentParameters.  
int[] newArrayContentIds = new int[] { 82 };  

// Define the array of source paths (these must be UNC) to load into addUpdateContentParameters.  
string[] newArrayContentSourcePath = new string[] { "\\\\ServerOne\\source1" };  

// Load the update content parameters into an object to pass to the method.  
Dictionary<string, object> addUpdateContentParameters = new Dictionary<string, object>();  
addUpdateContentParameters.Add("ContentIds", newArrayContentIds);  
addUpdateContentParameters.Add("ContentSourcePath", newArrayContentSourcePath);  
addUpdateContentParameters.Add("bRefreshDPs", false);  

AddUpdatestoSUMDeploymentPackage(WMIConnection,  
                                 "ABC00001",  
                                 addUpdateContentParameters);  
public void AddUpdatestoSUMDeploymentPackage(WqlConnectionManager connection,  
                                            string existingSUMPackageID,  
                                            Dictionary<string, object> addUpdateContentParameters)  
{  
    try  
    {  
        // Get the specific SUM Deployment Package to change.  
        IResultObject existingSUMDeploymentPackage = connection.GetInstance(@"SMS_SoftwareUpdatesPackage.PackageID='" + existingSUMPackageID + "'");  

        // Add updates to the existing SUM Deployment Package using the AddUpdateContent method.  
        // Note: The method will throw an exception, if the method is not able to add the content.  
        existingSUMDeploymentPackage.ExecuteMethod("AddUpdateContent", addUpdateContentParameters);  

        // Output a success message that the content was added.  
        Console.WriteLine("Added content to the SUM deployment package. ");                  
    }  
    catch (SmsException ex)  
    {  
        Console.WriteLine("Failed to add content to the SUM deployment package.");                  
        Console.WriteLine("Error: " + ex.Message);        
        throw;  
    }  
}  

예제 메서드에는 다음 매개 변수가 있습니다.

매개 변수 형식 설명
connection -관리: WqlConnectionManager SMS 공급자에 대한 유효한 연결입니다.
existingSUMPackageID -관리: String 기존 소프트웨어의 패키지 ID는 배포 패키지를 업데이트합니다.
addUpdateContentParameters - 관리형: dictionary 개체 메서드에 전달되고 메서드 호출과 함께 AddUpdateContent 사용되는 매개 변수 집합(ContentIDs, ContentSourcePath, bRefreshDPs)입니다.

코드 컴파일

이 C# 예제에는 다음이 필요합니다.

네임 스페이스

시스템

System.Collections.Generic

System.Text

Microsoft. ConfigurationManagement.ManagementProvider

Microsoft. ConfigurationManagement.ManagementProvider.WqlQueryEngine

어셈블리

adminui.wqlqueryengine

microsoft.configurationmanagement.managementprovider

강력한 프로그래밍

오류 처리에 대한 자세한 내용은 Configuration Manager 오류 정보를 참조하세요.

.NET Framework 보안

Configuration Manager 애플리케이션 보안에 대한 자세한 내용은 역할 기반 관리 Configuration Manager 참조하세요.

참고 항목

소프트웨어 업데이트 배포 정보배포 지점에 패키지를 할당하는 방법
SMS_SoftwareUpdatesPackage
클래스 SMS_SoftwareUpdatesPackage AddUpdateContent 메서드