일정 토큰을 만드는 방법

Configuration Manager 적절한 SMS_ST_ 일정 토큰 클래스의 인스턴스를 만들고 채워 일정 토큰을 만듭니다. SMS_ST schedule 클래스는 클래스의 SMS_ScheduleToken 자식 클래스이며 매일, 매주 및 매월과 같이 빈도가 다른 이벤트의 예약을 처리합니다.

SMS_ScheduleMethods WMI(Windows Management Instrumentation) 클래스 및 해당 ReadFromStringWriteToString 메서드는 일정 토큰을 간격 문자열로 디코딩하고 인코딩하는 데 사용됩니다. 그런 다음, 간격 문자열을 사용하여 개체를 정의하거나 수정할 때 일정 속성을 설정할 수 있습니다. 이 예제는 속성이 구성된 컬렉션에 대한 유지 관리 기간을 만드는 방법 항목 ServiceWindowSchedules 에서 확인할 수 있습니다.

일정 토큰을 만들고 간격 문자열로 변환하려면

  1. SMS_ScheduleToken 자식 클래스 중 하나를 사용하여 일정 토큰 개체를 만듭니다. 이 예제에서는 SMS_ST_RecurInterval 클래스를 사용합니다.

  2. 새 일정 토큰 개체의 속성을 채웁합니다.

  3. 클래스 및 WriteToString 메서드를 사용하여 일정 토큰 개체를 간격 문자열로 SMS_ScheduleMethods 변환합니다.

  4. 필요에 따라 간격 문자열을 사용하여 개체의 일정 속성을 채웁 수 있습니다.

예시

다음 예제 메서드는 일정 토큰 클래스의 SMS_ST_RecurInterval 인스턴스를 만들고 채웁니다. 또한 예제에서는 클래스 및 메서드를 사용하여 일정을 간격 문자열로 변환하는 SMS_ScheduleMethods 방법을 보여 있습니다 WriteToString .

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


Sub CreateDailyRecurringScheduleString(connection,   _  
                                       hourDuration, _  
                                       daySpan,      _   
                                       startTime,    _  
                                       isGmt)  

    ' Create a new recurring interval schedule object.  
    ' Note: There are several types of schedule classes available, each defines a different type of schedule.  
    Set recurInterval = connection.Get("SMS_ST_RecurInterval").SpawnInstance_  

    ' Populate the schedule properties.  
    recurInterval.DayDuration = 0  
    recurInterval.HourDuration = hourDuration  
    recurInterval.MinuteDuration = 0  
    recurInterval.DaySpan = daySpan  
    recurInterval.HourSpan = 0  
    recurInterval.MinuteSpan = 0  
    recurInterval.StartTime = startTime  
    recurInterval.IsGMT = isGmt  

    ' Call WriteToString method to decode the schedule token.  
    ' Note: The initial parameter of the WriteToString method requires an array.   
    Set clsScheduleMethod = connection.Get("SMS_ScheduleMethods")  
    clsScheduleMethod.WriteToString Array(recurInterval), scheduleString  

    ' Output schedule token as an interval string.  
    WScript.Echo "Schedule Token Interval String: " & scheduleString  

End Sub  

public void CreateDailyRecurringScheduleToken(WqlConnectionManager connection,  
                                              int hourDuration,   
                                              int daySpan,  
                                              string startTime,  
                                              bool isGmt)    
{  
    try  
    {                  
        // Create a new recurring interval schedule object.  
        // Note: There are several types of schedule classes available, each defines a different type of schedule.  
        IResultObject recurInterval = connection.CreateEmbeddedObjectInstance("SMS_ST_RecurInterval");  

        // Populate the schedule properties.  
        recurInterval["DayDuration"].IntegerValue = 0;  
        recurInterval["HourDuration"].IntegerValue = hourDuration;  
        recurInterval["MinuteDuration"].IntegerValue = 0;  
        recurInterval["DaySpan"].IntegerValue = daySpan;  
        recurInterval["HourSpan"].IntegerValue = 0;  
        recurInterval["MinuteSpan"].IntegerValue = 0;  
        recurInterval["StartTime"].StringValue = startTime;         
        recurInterval["IsGMT"].BooleanValue = isGmt;  

        // Creating array to use as a parameters for the WriteToString method.  
        List<IResultObject> scheduleTokens = new List<IResultObject>();  
        scheduleTokens.Add(recurInterval);  

        // Creating dictionary object to pass parameters to the WriteToString method.  
        Dictionary<string, object> inParams = new Dictionary<string, object>();  
        inParams["TokenData"] = scheduleTokens;  

        // Initialize the outParams object.  
        IResultObject outParams = null;  

        // Call WriteToString method to decode the schedule token.  
        outParams = connection.ExecuteMethod("SMS_ScheduleMethods", "WriteToString", inParams);  

        // Output schedule token as an interval string.  
        // Note: The return value for this method is always 0, so this check is just best practice.  
        if (outParams["ReturnValue"].IntegerValue == 0)  
        {  
            Console.WriteLine("Schedule Token Interval String: " + outParams["StringData"].StringValue);  
        }  
    }  
    catch (SmsException ex)  
    {  
        Console.WriteLine("Failed. Error: " + ex.InnerException.Message);  
    }  
}  

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

매개 변수 형식 설명
connection -관리: WqlConnectionManager
- VBScript: SWbemServices
SMS 공급자에 대한 유효한 연결입니다.
hourDuration -관리: Integer
-Vbscript: Integer
예약된 작업이 발생하는 시간 수입니다. 허용되는 값은 0-23 범위에 있습니다. 기본값은 기간이 없음을 나타내는 0입니다.
daySpan -관리: Integer
-Vbscript: Integer
일정 간격을 포함하는 일 수입니다. 허용되는 값은 0-31 범위에 있습니다. 기본값은 0입니다.
startTime - 관리: String (DateTime)
- VBScript: String (DateTime)
예약된 작업이 수행되는 날짜 및 시간입니다. 기본값은 "19700201000000.000000+***"입니다. 이는 (WMI) CIM DATETIME 값이 저장되는 형식입니다.
isGmt -관리: Boolean
-Vbscript: Boolean
true 시간이 UTC(협정 세계시)에 있으면 입니다. 기본값은 현지 시간으로 입니다 false.

코드 컴파일

C# 예제에는 다음과 같은 컴파일 요구 사항이 있습니다.

네임 스페이스

시스템

System.Collections.Generic

System.Text

Microsoft. ConfigurationManagement.ManagementProvider

Microsoft. ConfigurationManagement.ManagementProvider.WqlQueryEngine

어셈블리

microsoft.configurationmanagement.managmentprovider

adminui.wqlqueryengine

강력한 프로그래밍

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

.NET Framework 보안

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

참고 항목

Configuration Manager 소프트웨어 개발 키트
SMS_ST_NonRecurring 서버 WMI 클래스
SMS_ST_RecurInterval 서버 WMI 클래스
SMS_ST_RecurMonthlyByDate 서버 WMI 클래스
SMS_ST_RecurMonthlyByWeekday 서버 WMI 클래스
SMS_ST_RecurWeekly 서버 WMI 클래스
SMS_ScheduleMethods 서버 WMI 클래스
클래스 SMS_ScheduleMethods ReadFromString 메서드
클래스 SMS_ScheduleMethods WriteToString 메서드