C# AssignedSchedule 任务序列 SDK SCCM
C# AssignedSchedule Task Sequence SDK SCCM
我正在使用 SCCM SDK 并使用以下 C# 代码创建部署:
const Int32 OVERRIED_SERVICE_WINDOWS = 0x00100020;
const Int32 ENABLE_PRESENT = 0x01000000;
const Int32 REMOTE_FLAG = 0x00041040;
try
{
DateTime now = DateTime.Now;
IResultObject novoDeploy = connection.CreateInstance("SMS_Advertisement");
novoDeploy["CollectionID"].StringValue = collectionID;
novoDeploy["PackageID"].StringValue = pacote;
novoDeploy["ProgramName"].StringValue = nomePrograma;
novoDeploy["AdvertisementName"].StringValue = "Deploy Teste SDK";
novoDeploy["Comment"].StringValue = "Deploy realizado via SDK";
novoDeploy["AdvertFlags"].IntegerValue = novoDeploy["AdvertFlags"].IntegerValue | OVERRIED_SERVICE_WINDOWS;
novoDeploy["DeviceFlags"].IntegerValue = 0;//novoDeploy["DeviceFlags"].IntegerValue | ENABLE_PRESENT;
novoDeploy["RemoteClientFlags"].IntegerValue = novoDeploy["RemoteClientFlags"].IntegerValue | REMOTE_FLAG;
novoDeploy["AssignedScheduleEnabled"].BooleanValue = true;
novoDeploy["OfferType"].IntegerValue = 0;
novoDeploy["PresentTimeEnabled"].BooleanValue = true;
novoDeploy["PresentTime"].DateTimeValue = now;
novoDeploy["Priority"].IntegerValue = 1;
novoDeploy["TimeFlags"].IntegerValue = novoDeploy["TimeFlags"].IntegerValue | ENABLE_PRESENT;
List<IResultObject> collectionSchedule = novoDeploy.GetArrayItems("AssignedSchedule");
IResultObject collectionVariable =
connection.CreateEmbeddedObjectInstance("SMS_ST_NonRecurring");
collectionVariable["StartTime"].DateTimeValue = now;
collectionSchedule.Add(collectionVariable);
novoDeploy.SetArrayItems("AssignedSchedule", collectionSchedule);
novoDeploy.Put();
我需要在预定日期进行部署,但出现错误。
您知道我应该在 Advert Flags 字段中保留哪些设置来执行此计划部署吗?
非常感谢您的帮助!
问题是您尝试在此处写入 TimeFlags 属性:
novoDeploy["TimeFlags"].IntegerValue = novoDeploy["TimeFlags"].IntegerValue | ENABLE_PRESENT;
根据 documentation 是只读标志。
关于您的用例,它说:
Reserved for internal use. Flags that duplicate the information in the
time-related properties. Possible values are listed below. For
example, ENABLE_PRESENT is set when PresentTimeEnabled equals true.
因此,由于您已经设置了 PresentTimeEnabled,因此您只需省略该行就可以了。
我正在使用 SCCM SDK 并使用以下 C# 代码创建部署:
const Int32 OVERRIED_SERVICE_WINDOWS = 0x00100020;
const Int32 ENABLE_PRESENT = 0x01000000;
const Int32 REMOTE_FLAG = 0x00041040;
try
{
DateTime now = DateTime.Now;
IResultObject novoDeploy = connection.CreateInstance("SMS_Advertisement");
novoDeploy["CollectionID"].StringValue = collectionID;
novoDeploy["PackageID"].StringValue = pacote;
novoDeploy["ProgramName"].StringValue = nomePrograma;
novoDeploy["AdvertisementName"].StringValue = "Deploy Teste SDK";
novoDeploy["Comment"].StringValue = "Deploy realizado via SDK";
novoDeploy["AdvertFlags"].IntegerValue = novoDeploy["AdvertFlags"].IntegerValue | OVERRIED_SERVICE_WINDOWS;
novoDeploy["DeviceFlags"].IntegerValue = 0;//novoDeploy["DeviceFlags"].IntegerValue | ENABLE_PRESENT;
novoDeploy["RemoteClientFlags"].IntegerValue = novoDeploy["RemoteClientFlags"].IntegerValue | REMOTE_FLAG;
novoDeploy["AssignedScheduleEnabled"].BooleanValue = true;
novoDeploy["OfferType"].IntegerValue = 0;
novoDeploy["PresentTimeEnabled"].BooleanValue = true;
novoDeploy["PresentTime"].DateTimeValue = now;
novoDeploy["Priority"].IntegerValue = 1;
novoDeploy["TimeFlags"].IntegerValue = novoDeploy["TimeFlags"].IntegerValue | ENABLE_PRESENT;
List<IResultObject> collectionSchedule = novoDeploy.GetArrayItems("AssignedSchedule");
IResultObject collectionVariable =
connection.CreateEmbeddedObjectInstance("SMS_ST_NonRecurring");
collectionVariable["StartTime"].DateTimeValue = now;
collectionSchedule.Add(collectionVariable);
novoDeploy.SetArrayItems("AssignedSchedule", collectionSchedule);
novoDeploy.Put();
我需要在预定日期进行部署,但出现错误。 您知道我应该在 Advert Flags 字段中保留哪些设置来执行此计划部署吗?
非常感谢您的帮助!
问题是您尝试在此处写入 TimeFlags 属性:
novoDeploy["TimeFlags"].IntegerValue = novoDeploy["TimeFlags"].IntegerValue | ENABLE_PRESENT;
根据 documentation 是只读标志。 关于您的用例,它说:
Reserved for internal use. Flags that duplicate the information in the time-related properties. Possible values are listed below. For example, ENABLE_PRESENT is set when PresentTimeEnabled equals true.
因此,由于您已经设置了 PresentTimeEnabled,因此您只需省略该行就可以了。