public void Execute(IActivityRequest request, IActivityResponse response) { SCCMServer = settings.SCCMSERVER; userName = settings.UserName; password = settings.Password; String pkgID = request.Inputs["Existing Package ID"].AsString(); String prgName = request.Inputs["Existing Program Name"].AsString(); String colID = request.Inputs["Existing Collection ID"].AsString(); String advName = request.Inputs["New Advertisement Name"].AsString(); String advComment = request.Inputs["New Advertisement Comment"].AsString(); int advFlags = (int)request.Inputs["New Advertisement Flags"].AsUInt32(); String advStartDate = request.Inputs["New Advertisement Start Date"].AsString(); String advStartOfferEnabled = request.Inputs["New Advertisement Start Offer Enabled"].AsString(); String advIncludeSubCollections = request.Inputs["New Advertisement Include Sub Collection"].AsString(); bool advertStartOfferEnabled = true; switch (advStartOfferEnabled) { case "True": advertStartOfferEnabled = true; break; case "False": advertStartOfferEnabled = false; break; } //Setup WQL Connection and WMI Management Scope WqlConnectionManager connection = CM2012Interop.connectSCCMServer(SCCMServer, userName, password); using (connection) { IResultObject col = CM2012Interop.createSCCMAdvertisement(connection, colID, pkgID, prgName, advName, advComment, advFlags, advStartDate, advertStartOfferEnabled); //If advetisement should not include subcollection modify that property if (advIncludeSubCollections.Equals("False")) { CM2012Interop.modifySCCMAdvertisement(connection, col["AdvertisementID"].StringValue, "BooleanValue", "includeSubCollection", "False"); } if (col != null) { response.WithFiltering().PublishRange(getObjects(col)); } response.Publish("Number of Advertisements", ObjCount); } }