Notitie
Voor toegang tot deze pagina is autorisatie vereist. U kunt proberen u aan te melden of de directory te wijzigen.
Voor toegang tot deze pagina is autorisatie vereist. U kunt proberen de mappen te wijzigen.
U maakt in Configuration Manager een lijst met updates die een reeks software-updates bevat door een exemplaar van de klasse SMS_AuthorizationList te maken en de eigenschappen in te vullen.
Een lijst met updates maken
Stel een verbinding in met de sms-provider.
Maak het nieuwe updatelijstobject met behulp van de
SMS_AuthorizationListklasse.Vul de eigenschappen van de nieuwe updatelijst in.
Sla de lijst met nieuwe updates en eigenschappen op.
Voorbeeld
In de volgende voorbeeldmethode ziet u hoe u een updatelijst met een set software-updates kunt maken door een exemplaar van de SMS_AuthorizationList klasse te maken en de eigenschappen in te vullen.
Belangrijk
Voor LocalizedInformation de eigenschap die in dit voorbeeld wordt gebruikt, is een objectmatrix (ingesloten matrix) van de beschrijvingsgegevens vereist.
In het voorbeeld is de LocaleID eigenschap gecodeerd in het Engels (VS). Als u de landinstelling voor niet-Amerikaanse installaties, kunt u deze ophalen uit de eigenschap SMS_Identification Server WMI ClassLocaleID .
Zie Codefragmenten van Configuration Manager aanroepen voor meer informatie over het aanroepen van de voorbeeldcode.
In het volgende voorbeeld ziet u de subroutine-aanroep in 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)
In het volgende voorbeeld wordt de method call in C# weergegeven:
// 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;
}
}
De voorbeeldmethode heeft de volgende parameters:
| Parameter | Type | Beschrijving |
|---|---|---|
Connection |
- Beheerd: WqlConnectionManager- VBScript: SWbemServices |
Een geldige verbinding met de sms-provider. |
newUpdates |
- Beheerd: Integer array- VBScript: Integer matrix |
Een matrix van de updates die is gekoppeld aan de lijst met updates. |
newDescriptionInfo |
- Beheerd: Object array- VBScript: Object matrix |
Een objectmatrix (ingesloten eigenschappen) van het type LocalizedInformation. |
De code compileren
Dit C#-voorbeeld vereist:
Naamruimten
Systeem
System.Collections.Generic
System.Text
Microsoft.ConfigurationManagement.ManagementProvider
Microsoft.ConfigurationManagement.ManagementProvider.WqlQueryEngine
bijeenkomst
adminui.wqlqueryengine
microsoft.configurationmanagement.managementprovider
Robuust programmeren
Zie Info over fouten in Configuration Manager voor meer informatie over foutafhandeling.
.NET Framework-beveiliging
Zie Rolgebaseerd beheer van Configuration Manager voor meer informatie over het beveiligen van Configuration Manager-toepassingen.
Zie ook
Informatie over implementaties van software-updatesSMS_AuthorizationList