Como criar uma lista de atualizações

Você cria uma lista de atualizações que contém um conjunto de atualizações de software, em Configuration Manager, criando uma instância da classe SMS_AuthorizationList e preenchendo as propriedades.

Para criar uma lista de atualização

  1. Configure uma conexão com o provedor de SMS.

  2. Crie o novo objeto de lista de atualização usando a SMS_AuthorizationList classe.

  3. Preencha as novas propriedades da lista de atualização.

  4. Salve a nova lista de atualização e propriedades.

Exemplo

O método de exemplo a seguir mostra como criar uma lista de atualizações que contém um conjunto de atualizações de software criando uma instância da SMS_AuthorizationList classe e preenchendo as propriedades.

Importante

A LocalizedInformation propriedade usada neste exemplo requer uma matriz de objeto (matriz inserida) com as informações de descrição.

No exemplo, a LocaleID propriedade é codificada em código fixo para inglês (EUA). Se você precisar da localidade para telefones fora dos EUA existentes, você pode obtê-lo na propriedade Classe LocaleIDWMI do SMS_Identification Server.

Para obter informações sobre como chamar o código de exemplo, consulte Chamando trechos de código do Configuration Manager.

O exemplo a seguir mostra a chamada de sub-rotina no Visual Basic:


' Prework for CreateSUMUpdateList
' Create the array of CI_IDs.
dim newUpdates
newUpdates = Array(9)

' Create and populate an SMS_CI_LocalizedProperties object.
set SMSCILocalizedProperties = swbemservices.Get("SMS_CI_LocalizedProperties").SpawnInstance_

SMSCILocalizedProperties.Description = "Test Description"
SMSCILocalizedProperties.DisplayName = "Test Display Name"
SMSCILocalizedProperties.InformativeURL = "Test URL"
SMSCILocalizedProperties.LocaleID = "1033"

' Create an array to hold the SMS_CI_LocalizedProperties object.
dim newDescriptionInfo
newDescriptionInfo = Array(SMSCILocalizedProperties)

' Call the CreateSUMUpdateList method.
Call CreateSUMUpdateList(swbemServices,       _
                         newUpdates,          _
                         newDescriptionInfo)

O exemplo a seguir mostra a chamada de método em C#:


// Prework for CreateSUMUpdateList
// Create array list (to hold the array of Localized Properties).
List<IResultObject> newDescriptionInfo = new List <IResultObject>();
IResultObject SMSCILocalizedProperties = WMIConnection.CreateEmbeddedObjectInstance("SMS_CI_LocalizedProperties");

// Populate the initial array values (this could be a loop to added more localized info).
SMSCILocalizedProperties["Description"].StringValue = "4 CI_IDs - 9,34,53,72 ";
SMSCILocalizedProperties["DisplayName"].StringValue = "Test Display Name";
SMSCILocalizedProperties["InformativeURL"].StringValue = "Test URL";
SMSCILocalizedProperties["LocaleID"].StringValue = "1033";

// Add the 'embedded properties' to newDescriptionInfo.
newDescriptionInfo.Add(SMSCILocalizedProperties);

// Create the array of CI_IDs.
int[] newCI_ID = new int[] { 9, 34, 53, 72 };

// Call the CreateSUMUpdateList method.
SUMSnippets.CreateSUMUpdateList(WMIConnection,
                                newCI_ID,
                                newDescriptionInfo);


Sub CreateSUMUpdateList(connection,         _
                        newUpdates,         _
                        newDescriptionInfo)

    ' Create the new UpdateList object.
    Set newUpdateList = connection.Get("SMS_AuthorizationList").SpawnInstance_

    ' Populate the UpdateList properties.
    ' Updates is an int32 array that maps to the CI_ID in SMS_SoftwareUpdate.
    newUpdateList.Updates = newUpdates
    ' Need to pass embedded properties (LocalizedInformation) here.
    newUpdateList.LocalizedInformation = newDescriptionInfo

    ' Save the new UpdateList and properties.
    newUpdateList.Put_

    ' Output the new UpdateList name.
    Wscript.Echo "Created Update List " & newUpdateList.LocalizedDisplayName

End Sub

public void CreateSUMUpdateList(WqlConnectionManager connection,
                                 int [] newUpdates,
                                 List<IResultObject> newDescriptionInfo)
{
    try
    {
        // Create the new SMS_AuthorizationList object.
        IResultObject newUpdateList = connection.CreateInstance("SMS_AuthorizationList");

        // Populate the new SMS_AuthorizationList object properties.
        // Updates is an int32 array that maps to the CI_ID in SMS_SoftwareUpdate.
        newUpdateList["Updates"].IntegerArrayValue = newUpdates;
        // Pass embedded properties (LocalizedInformation) here.
        newUpdateList.SetArrayItems("LocalizedInformation", newDescriptionInfo);

        // Save changes.
        newUpdateList.Put();

        Console.WriteLine();
        Console.WriteLine("Created Update List. " );

    }

    catch (SmsException ex)
    {
        Console.WriteLine("Failed to create update list. Error: " + ex.Message);
        throw;
    }
}

O método de exemplo tem os seguintes parâmetros:

Parâmetro Tipo Descrição
Connection - Gerenciado: WqlConnectionManager
- VBScript: SWbemServices
Uma conexão válida com o provedor de SMS.
newUpdates - Gerenciado: Integer matriz
- VBScript: Integer matriz
Uma matriz das atualizações associada à Lista de Atualizações.
newDescriptionInfo - Gerenciado: Object matriz
- VBScript: Object matriz
Uma matriz de objetos (propriedades inseridas) do tipo LocalizedInformation.

Compilando o código

Este exemplo do C# exige:

Namespaces

System

System.Collections.Generic

System.Text

Microsoft.ConfigurationManagement.ManagementProvider

Microsoft.ConfigurationManagement.ManagementProvider.WqlQueryEngine

Assembly

adminui.wqlqueryengine

Microsoft.ConfigurationManagement.ManagementProvider

Programação robusta

Para obter mais informações sobre o tratamento de erros, consulte Sobre erros do Configuration Manager.

Segurança do .NET Framework

Para obter mais informações sobre como proteger aplicativos do Configuration Manager, consulte Administração baseada em funções do Configuration Manager.

Confira também

Sobre implantações de atualização de softwareSMS_AuthorizationList