protected override void ExecuteCmdlet() { var rootWebServerRelativeUrl = (CurrentWeb.Context as ClientContext).Site.RootWeb.EnsureProperty(r => r.ServerRelativeUrl); var serverRelativeUrl = CurrentWeb.EnsureProperty(w => w.ServerRelativeUrl); if (ColorPaletteUrl == null) { ColorPaletteUrl = "/_catalogs/theme/15/palette001.spcolor"; } if (!ColorPaletteUrl.ToLower().StartsWith(rootWebServerRelativeUrl.ToLower())) { ColorPaletteUrl = UrlUtility.Combine(rootWebServerRelativeUrl, ColorPaletteUrl); } if (!string.IsNullOrEmpty(FontSchemeUrl) && !FontSchemeUrl.ToLower().StartsWith(rootWebServerRelativeUrl.ToLower())) { FontSchemeUrl = UrlUtility.Combine(rootWebServerRelativeUrl, FontSchemeUrl); } if (!string.IsNullOrEmpty(BackgroundImageUrl) && BackgroundImageUrl.ToLower().StartsWith(rootWebServerRelativeUrl.ToLower())) { BackgroundImageUrl = UrlUtility.Combine(rootWebServerRelativeUrl, BackgroundImageUrl); } CurrentWeb.SetThemeByUrl(ColorPaletteUrl, FontSchemeUrl, BackgroundImageUrl, ResetSubwebsToInherit, UpdateRootWebOnly); ClientContext.ExecuteQueryRetry(); if (!CurrentWeb.IsNoScriptSite()) { ComposedLook composedLook; // Set the corresponding property bag value which is used by the provisioning engine if (CurrentWeb.PropertyBagContainsKey(PROPBAGKEY)) { composedLook = JsonSerializer.Deserialize <ComposedLook>(CurrentWeb.GetPropertyBagValueString(PROPBAGKEY, "")); } else { composedLook = new ComposedLook { BackgroundFile = "" }; CurrentWeb.EnsureProperty(w => w.AlternateCssUrl); composedLook.ColorFile = ""; CurrentWeb.EnsureProperty(w => w.MasterUrl); composedLook.FontFile = ""; CurrentWeb.EnsureProperty(w => w.SiteLogoUrl); } composedLook.Name = composedLook.Name ?? "Custom by PnP PowerShell"; composedLook.ColorFile = ColorPaletteUrl ?? composedLook.ColorFile; composedLook.FontFile = FontSchemeUrl ?? composedLook.FontFile; composedLook.BackgroundFile = BackgroundImageUrl ?? composedLook.BackgroundFile; var composedLookJson = JsonSerializer.Serialize(composedLook); CurrentWeb.SetPropertyBagValue(PROPBAGKEY, composedLookJson); } }
protected override void ExecuteCmdlet() { if (string.IsNullOrEmpty(Folder)) { if (!string.IsNullOrEmpty(Key)) { WriteObject(CurrentWeb.GetPropertyBagValueString(Key, string.Empty)); } else { CurrentWeb.EnsureProperty(w => w.AllProperties); var values = CurrentWeb.AllProperties.FieldValues.Select(x => new PropertyBagValue() { Key = x.Key, Value = x.Value }); WriteObject(values, true); } } else { // Folder Property Bag CurrentWeb.EnsureProperty(w => w.ServerRelativeUrl); var folderUrl = UrlUtility.Combine(CurrentWeb.ServerRelativeUrl, Folder); var folder = CurrentWeb.GetFolderByServerRelativePath(ResourcePath.FromDecodedUrl(folderUrl)); folder.EnsureProperty(f => f.Properties); if (!string.IsNullOrEmpty(Key)) { var value = folder.Properties.FieldValues.FirstOrDefault(x => x.Key == Key); WriteObject(value.Value, true); } else { var values = folder.Properties.FieldValues.Select(x => new PropertyBagValue() { Key = x.Key, Value = x.Value }); WriteObject(values, true); } } }
protected override void ExecuteCmdlet() { if (CurrentWeb.PropertyBagContainsKey("_PnP_ProvisioningTemplateComposedLookInfo") && !DetectCurrentComposedLook) { try { WriteWarning("The information presented here is based upon the fact that the theme has been set using either the PnP Provisioning Engine or using the Set-PnPTheme cmdlet. This information is retrieved from a propertybag value and may differ from the actual site."); var composedLook = JsonSerializer.Deserialize <ComposedLook>(CurrentWeb.GetPropertyBagValueString("_PnP_ProvisioningTemplateComposedLookInfo", "")); WriteObject(composedLook); } catch { var themeEntity = CurrentWeb.GetCurrentComposedLook(); WriteObject(themeEntity); } } else { var themeEntity = CurrentWeb.GetCurrentComposedLook(); WriteObject(themeEntity); } }