public SPOFolder Read(SPOWeb spoWeb)
        {
            if (string.IsNullOrEmpty(_serverRelativeUrl))
            {
                throw new ArgumentNullException("The server relative URL was not provided.");
            }

            return(spoWeb.GetFolderByServerRelativeUrl(_serverRelativeUrl));
        }
Beispiel #2
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            var ctx = base.Context;

            SPOWeb web = new SPOWeb(ctx.Site.OpenWeb(Web.Read()));

            WriteObject(web.GetFolderByServerRelativeUrl(Url));
        }
Beispiel #3
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            var    ctx  = base.Context;
            string surl = Identity.Read();

            if (!base.ShouldProcess(Identity.ToString()))
            {
                return;
            }

            SPOWeb web = new SPOWeb(ctx.Site.OpenWeb(surl));

            web.ApplyTheme(ColorPaletteUrl, FontSchemeUrl, BackgroundImageUrl, ShareGenerated);
        }
Beispiel #4
0
        private void IterateWebs(CmdletContext ctx, Web parentWeb, bool detailed)
        {
            var childWebs = parentWeb.Webs;

            ctx.Load(childWebs);
            ctx.ExecuteQuery();
            foreach (Web childWeb in childWebs)
            {
                SPOWeb.LoadWeb(ctx, childWeb, detailed);
                SPOWeb web = new SPOWeb(childWeb);
                if (web.WebTemplate != "APP" || (web.WebTemplate == "APP" && IncludeAppWebs))
                {
                    WriteObject(web);
                }
                IterateWebs(ctx, childWeb, detailed);
            }
        }
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            var ctx = base.Context;
            Web web = ctx.Site.OpenWeb(ParentWeb.Read());

            var webci = new WebCreationInformation
            {
                Description = Description,
                Language    = Language,
                Title       = Title,
                Url         = Url,
                UseSamePermissionsAsParentSite = !UniquePermissions,
                WebTemplate = WebTemplate
            };
            Web newWeb = web.Webs.Add(webci);

            ctx.ExecuteQuery();
            SPOWeb.LoadWeb(ctx, newWeb, true);
            WriteObject(new SPOWeb(newWeb));
        }
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            var ctx = base.Context;

            SPOWeb web = new SPOWeb(ctx.Site.OpenWeb(Web.Read()));

            if (ParameterSetName == "File")
            {
                foreach (var filePipe in File)
                {
                    var file = filePipe.Read(web);
                    WriteFile(TargetFolder, file);
                }
            }
            else if (ParameterSetName == "Folder")
            {
                var folder = Folder.Read(web);
                WriteFiles(TargetFolder, folder);
            }
        }
Beispiel #7
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            var ctx = base.Context;

            if (Identity == null)
            {
                Web rootWeb = ctx.Site.RootWeb;
                SPOWeb.LoadWeb(ctx, rootWeb, Detail);
                WriteObject(new SPOWeb(rootWeb));
                IterateWebs(ctx, rootWeb, Detail);
            }
            else
            {
                string surl = Identity.Read();
                Web    web  = ctx.Site.OpenWeb(surl);
                SPOWeb.LoadWeb(ctx, web, Detail);

                WriteObject(new SPOWeb(web));
            }
        }
Beispiel #8
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            var ctx = base.Context;

            ctx.Load(ctx.Site, s => s.ServerRelativeUrl);
            ctx.ExecuteQuery();

            FileInfo file     = new FileInfo(LiteralPath);
            string   leafName = file.Name;
            string   url      = ctx.Site.ServerRelativeUrl.TrimEnd('/') + "/_catalogs/solutions/" + leafName;

            using (FileStream stream = new FileStream(LiteralPath, FileMode.Open))
            {
                Microsoft.SharePoint.Client.File.SaveBinaryDirect(ctx,
                                                                  url, stream, Overwrite);
            }
            SPOWeb web = new SPOWeb(ctx.Site.RootWeb);

            WriteObject(web.GetFileByServerRelativeUrl(url));
        }
 public SPOWebPipeBind(SPOWeb inputObject)
 {
     _web  = inputObject.Web;
     _surl = inputObject.ServerRelativeUrl;
 }
        public SPOFolder Read(Web web)
        {
            SPOWeb spoWeb = new SPOWeb(web);

            return(Read(spoWeb));
        }
Beispiel #11
0
        internal static SPOWikiPage AddWikiPage(SPOWeb web, string wikiPageLibraryUrlOrTitle, string wikiPageName, bool throwIfExists)
        {
            SPOList list = web.GetList(wikiPageLibraryUrlOrTitle, false);

            return(AddWikiPage(list, wikiPageName, throwIfExists));
        }
Beispiel #12
0
 public static SPOWikiPage AddWikiPage(SPOWeb web, string wikiPageLibraryUrlOrTitle, string wikiPageName)
 {
     return(AddWikiPage(web, wikiPageLibraryUrlOrTitle, wikiPageName, false));
 }
 public void AddFieldLinks(SPOWeb web, params string[] fieldsToAdd)
 {
     AddFieldLinks(web.Web.AvailableFields, false, fieldsToAdd);
 }
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            var ctx  = base.Context;
            var cweb = ctx.Site.OpenWeb(Identity.Read());

            SPOWeb.LoadWeb(ctx, cweb, true);
            SPOWeb web = new SPOWeb(cweb);

            if (base.ParameterSetName == "BreakRoleInheritance")
            {
                if (web.HasUniqueRoleAssignments)
                {
                    throw new ArgumentException("The specified Site already has unique role assignments.");
                }

                if (base.Fields.Contains("BreakRoleInheritance") && BreakRoleInheritance)
                {
                    web.Web.BreakRoleInheritance(CopyRoleAssignments, ClearScopes);
                    web.Web.Context.ExecuteQuery();

                    Identity.Refresh();
                    web.Refresh();
                    WriteObject(web);
                    return;
                }
            }
            else if (base.ParameterSetName == "ResetRoleInheritance")
            {
                if (!web.HasUniqueRoleAssignments)
                {
                    throw new ArgumentException("The specified Site does not have unique role assignments.");
                }

                if (base.Fields.Contains("ResetRoleInheritance") && ResetRoleInheritance)
                {
                    web.Web.ResetRoleInheritance();
                    web.Web.Context.ExecuteQuery();

                    Identity.Refresh();
                    web.Refresh();
                    WriteObject(web);
                    return;
                }
            }
            else
            {
                if ((base.Fields.Contains("AssociatedMemberGroup") ||
                     base.Fields.Contains("AssociatedOwnerGroup") ||
                     base.Fields.Contains("AssociatedVisitorGroup")) && !web.HasUniqueRoleAssignments)
                {
                    throw new ArgumentException("You can only set the associated member, owner, and visitor groups when the site has unique permissions (does not inherit).");
                }

                if (base.Fields.Contains("CustomMasterUrl"))
                {
                    web.CustomMasterUrl = CustomMasterUrl;
                }

                if (base.Fields.Contains("MasterUrl"))
                {
                    web.MasterUrl = MasterUrl;
                }

                if (base.Fields.Contains("Title"))
                {
                    web.Title = Title;
                }

                if (base.Fields.Contains("Description"))
                {
                    web.Description = Description;
                }

                if (base.Fields.Contains("EnableMinimalDownload"))
                {
                    web.EnableMinimalDownload = EnableMinimalDownload;
                }

                if (base.Fields.Contains("QuickLaunchEnabled"))
                {
                    web.QuickLaunchEnabled = QuickLaunchEnabled;
                }

                if (base.Fields.Contains("SaveSiteAsTemplateEnabled"))
                {
                    web.SaveSiteAsTemplateEnabled = SaveSiteAsTemplateEnabled;
                }

                if (base.Fields.Contains("ServerRelativeUrl"))
                {
                    web.ServerRelativeUrl = ServerRelativeUrl;
                }

                if (base.Fields.Contains("SyndicationEnabled"))
                {
                    web.SyndicationEnabled = SyndicationEnabled;
                }

                if (base.Fields.Contains("TreeViewEnabled"))
                {
                    web.TreeViewEnabled = TreeViewEnabled;
                }

                if (base.Fields.Contains("UIVersion"))
                {
                    web.UIVersion = UIVersion;
                }

                if (base.Fields.Contains("UIVersionConfigurationEnabled"))
                {
                    web.UIVersionConfigurationEnabled = UIVersionConfigurationEnabled;
                }

                if (base.Fields.Contains("AssociatedMemberGroup"))
                {
                    web.AssociatedMemberGroup = AssociatedMemberGroup.Read();
                }

                if (base.Fields.Contains("AssociatedOwnerGroup"))
                {
                    web.AssociatedOwnerGroup = AssociatedOwnerGroup.Read();
                }

                if (base.Fields.Contains("AssociatedVisitorGroup"))
                {
                    web.AssociatedVisitorGroup = AssociatedVisitorGroup.Read();
                }

                web.Update();

                Identity.Refresh();
                web.Refresh();
                WriteObject(web);
            }
        }