배포 패키지에서 업데이트 삭제하는 방법

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

소프트웨어 업데이트 배포 패키지에서 업데이트를 삭제하려면

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

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

  3. 메서드를 사용하여 RemoveContent 기존 소프트웨어 업데이트 관리 패키지에서 업데이트 콘텐츠를 제거합니다.

예시

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

중요

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

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

C#의 메서드 호출 예:


// Prework for RemoveUpdatesfromSUMDeploymentPackage.  
// Define the array of Content IDs to load into the content parameters.  
int[] newArrayContentIDs2 = new int[] { 82 };  

// Load the update content parameters into an object to pass to the method.  
Dictionary<string, object> removeContentParameters = new Dictionary<string, object>();  
removeContentParameters.Add("ContentIDs", newArrayContentIDs2);  
removeContentParameters.Add("bRefreshDPs", true);  

// Call the RemoveUpdatesfromSUMDeploymentPackage method.  
RemoveUpdatesfromSUMDeploymentPackage(WMIConnection,  
                                      "ABC00001",  
                                      removeContentParameters);  


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

        // Remove updates from the existing SUM Deployment Package using the RemoveContent method.  
        // Note: The method will throw an exception, if the method is not able to add the content.  
        IResultObject result = existingSUMDeploymentPackage.ExecuteMethod("RemoveContent", removeContentParameters);  

        // Output a success message.  
        Console.WriteLine("Removed content from the deployment package. ");  

    }  
    catch (SmsException ex)  
    {  
        Console.WriteLine("Failed to remove content from the deployment package. Error: " + ex.Message);  
        throw;  
    }  
}  

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

매개 변수 형식 설명
connection -관리: WqlConnectionManager SMS 공급자에 대한 유효한 연결입니다.
existingSUMPackageID -관리: String 기존 소프트웨어 업데이트 관리 패키지의 패키지 ID입니다.
removecontentParameters -관리: dictionary object 메서드에 전달되고 메서드 호출과 함께 RemoveContent 사용되는 매개 변수 집합(ContentIDs, 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 RemoveContent 메서드