I am using the SCCM SDK and creating a deploy using the C# code below:
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();
I need to deploy with a scheduled date, but I'm getting errors. Do you know what settings I should leave in the Advert Flags fields to perform this scheduled deploy?
Thanks a lot for the help!
The problem is that you try to write to the TimeFlags property here:
novoDeploy["TimeFlags"].IntegerValue = novoDeploy["TimeFlags"].IntegerValue | ENABLE_PRESENT;
which according to the documentation is a ReadOnly flag. Regarding your use case it says:
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.
So as you already set PresentTimeEnabled you should be fine with just leaving out that line.