Poznámka:
Přístup k této stránce vyžaduje autorizaci. Můžete se zkusit přihlásit nebo změnit adresáře.
Přístup k této stránce vyžaduje autorizaci. Můžete zkusit změnit adresáře.
V Configuration Manager se pro přiřazení standardních hodnot konfigurace ke kolekci vytvoří instance přiřazení, naplní se minimální sadou požadovaných hodnot a uloží se.
Přiřazení standardních hodnot konfigurace
Nastavte připojení k poskytovateli serveru SMS.
Vytvořte instanci objektu
SMS_BaselineAssignment.Vyplňte vlastnosti instance.
Uložte novou
SMS_BaselineAssignmentinstanci.
Příklad
Následující příklady kódu ukazují, jak vytvořit instanci přiřazení podle směrného plánu.
Informace o volání ukázkového kódu najdete v tématu Volání Configuration Manager fragmentů kódu.
Sub DCMCreateAssignment(swbemServices, _
baselineID, _
applyToSubTargets, _
assignmentAction, _
assignmentName, _
assignmentDescription, _
desiredConfigType, _
distributionPointLocality, _
evaluationSchedule, _
logComplianceToWinEvent, _
notifyUser, _
sendDetailedNonComplianceStatus, _
startTime, _
suppressReboot, _
targetCollectionID, _
useGMTTimes)
' Create new assignment object.
set newAssignment = swbemServices.Get("SMS_BaselineAssignment").SpawnInstance_()
' Assign variable values to assignment properties.
' //
' // The following properties are set by the provider on put():
' // AssignmentID
' // AssignmentUniqueID
' // SourceSite
' // CreationTime
newAssignment.ApplyToSubTargets = applyToSubTargets
newAssignment.AssignmentAction = assignmentAction
newAssignment.AssignmentName = assignmentName
newAssignment.AssignmentDescription = assignmentDescription
newAssignment.DesiredConfigType = desiredConfigType
newAssignment.DPLocality = distributionPointLocality
newAssignment.EvaluationSchedule = evaluationSchedule
newAssignment.LogComplianceToWinEvent = logComplianceToWinEvent
newAssignment.NotifyUser = notifyUser
newAssignment.SendDetailedNonComplianceStatus = sendDetailedNonComplianceStatus
newAssignment.StartTime = startTime
newAssignment.SuppressReboot = suppressReboot
newAssignment.TargetCollectionID = targetCollectionID
newAssignment.UseGMTTimes = useGMTTimes
newAssignment.AssignedCIs = Array(baselineID)
' Save assignment.
newAssignment.Put_
Wscript.Echo " "
Wscript.Echo "Created new assignment."
End Sub
public void DCMCreateAssignment(WqlConnectionManager connection,
bool applyToSubTargets,
int assignmentAction,
string assignmentName,
string assignmentDescription,
string desiredConfigType,
int distributionPointLocality,
string evaluationSchedule,
bool logComplianceToWinEvent,
bool notifyUser,
bool sendDetailedNonComplianceStatus,
string startTime,
int suppressReboot,
string targetCollectionID,
bool useGMTTimes,
int baselineID)
{
// Set required variables.
// Set AssignedCIs like array with a known baseline id (this is the initial creation of the assignment, so no existing values).
int[] arrayBaselineNumbers = new int[] { baselineID };
try
{
// Create new assignment object.
IResultObject newAssignment = connection.CreateInstance("SMS_BaselineAssignment");
// Assign variable values to assignment properties.
//
// The following properties are set by the provider on put():
// AssignmentID
// AssignmentUniqueID
// SourceSite
// CreationTime
newAssignment["ApplyToSubTargets"].BooleanValue = applyToSubTargets;
newAssignment["AssignmentAction"].IntegerValue = assignmentAction;
newAssignment["AssignmentName"].StringValue = assignmentName;
newAssignment["AssignmentDescription"].StringValue = assignmentDescription;
newAssignment["DesiredConfigType"].StringValue = desiredConfigType;
newAssignment["DPLocality"].IntegerValue = distributionPointLocality;
newAssignment["EvaluationSchedule"].StringValue = evaluationSchedule;
newAssignment["LogComplianceToWinEvent"].BooleanValue = logComplianceToWinEvent;
newAssignment["NotifyUser"].BooleanValue = notifyUser;
newAssignment["SendDetailedNonComplianceStatus"].BooleanValue = sendDetailedNonComplianceStatus;
newAssignment["StartTime"].StringValue = startTime;
newAssignment["SuppressReboot"].IntegerValue = suppressReboot;
newAssignment["TargetCollectionID"].StringValue = targetCollectionID;
newAssignment["AssignedCIs"].IntegerArrayValue = arrayBaselineNumbers;
newAssignment["UseGMTTimes"].BooleanValue = useGMTTimes;
// Save assignment object.
newAssignment.Put();
}
catch (SmsException ex)
{
Console.WriteLine("Failed to create new assignment." + "\\n" + ex.Message);
throw;
}
Console.WriteLine("Created new assignment.");
}
Ukázková metoda má následující parametry:
| Parametr | Typ | Popis |
|---|---|---|
- connection- swbemServices |
-Řízen: WqlConnectionManager- VBScript: SWbemServices |
Platné připojení k poskytovateli serveru SMS. |
applyToSubTargets |
-Řízen: Boolean- VBScript: Boolean |
true a použijete přiřazení položky konfigurace na podsbídku. |
assignmentAction |
-Řízen: Integer- VBScript: Integer |
Akce přidružená k přiřazení položky konfigurace |
assignmentName |
-Řízen: String- VBScript: String |
assignmentName |
assignmentDescription |
-Řízen: String- VBScript: String |
Název místního přiřazení. |
desiredConfigType |
-Řízen: String- VBScript: String |
Typ položky konfigurace. |
distributionPointLocality |
-Řízen: Integer- VBScript: Integer |
Příznaky, které určují, jak klient získá distribuční body podle umístění distribučního bodu. |
evaluationSchedule |
-Řízen: String- VBScript: String |
Plán vyhodnocení zadání. |
logComplianceToWinEvent |
-Řízen: Boolean- VBScript: Boolean |
true a protokolovat stav dodržování předpisů do protokolů událostí Systému Windows. |
notifyUser |
-Řízen: Boolean- VBScript: Boolean |
true upozorňovat uživatele, když je k dispozici položka konfigurace. |
sendDetailedNonComplianceStatus |
-Řízen: Boolean- VBScript: Boolean |
true a odešlete podrobnou zprávu o stavu nedodržování předpisů. |
startTime |
-Řízen: String- VBScript: String |
Datum a čas, kdy bylo původně nabídnuto přiřazení položky konfigurace. |
suppressReboot |
-Řízen: Integer- VBScript: Integer |
Hodnota označující, jestli klient nemá restartovat počítač, pokud po použití položky konfigurace čeká na restartování. |
targetCollectionID |
-Řízen: String- VBScript: String |
Identifikátor kolekce, na kterou je přiřazení zaměřeno. |
useGMTTimes |
-Řízen: Boolean- VBScript: Boolean |
true pokud jsou časy a plány ve standardu UTC (Universal Coordinated Time). |
baselineID |
- Spravované: Integer Pole- VBScript: Integer Pole |
Pole ID položek konfigurace, na které přiřazení cílí |
Kompilace kódu
Obory názvů
Systém
System.Collections.Generic
System.ComponentModel
Microsoft.ConfigurationManagement.ManagementProvider
Microsoft.ConfigurationManagement.ManagementProvider.WqlQueryEngine
Shromáždění
adminui.wqlqueryengine
microsoft.configurationmanagement.managementprovider
Robustní programování
Další informace o zpracování chyb najdete v tématu Informace o chybách Configuration Manager.
Zabezpečení rozhraní .NET Framework
Další informace o zabezpečení Configuration Manager aplikací najdete v tématu Configuration Manager správa na základě rolí.
Viz taky
Přehled standardních hodnot konfigurace a objektů položek konfiguracePostup připojení k poskytovateli Configuration Manager pomocí spravovaného kóduPostup připojení k poskytovateli Configuration Manager pomocíserverové třídy služby WMI SMS_BaselineAssignment