Esempio n. 1
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));
        }
Esempio n. 3
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));
            }
        }
        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);
            }
        }