Ejemplo n.º 1
0
        protected override void ExecuteCmdlet()
        {
            var url       = SelectedWeb.EnsureProperty(w => w.Url);
            var tenantUrl = UrlUtilities.GetTenantAdministrationUrl(ClientContext.Url);

            using (var tenantContext = ClientContext.Clone(tenantUrl))
            {
                var tenant = new Tenant(tenantContext);
                var webUrl = url;
                if (!string.IsNullOrEmpty(WebUrl))
                {
                    try
                    {
                        var uri = new System.Uri(WebUrl);
                        webUrl = WebUrl;
                    }
                    catch
                    {
                        ThrowTerminatingError(new ErrorRecord(new System.Exception("Invalid URL"), "INVALIDURL", ErrorCategory.InvalidArgument, WebUrl));
                    }
                }
                TenantSiteDesign design = Identity.GetTenantSiteDesign(tenant);
                if (design != null)
                {
                    var results = tenant.ApplySiteDesign(SelectedWeb.Url, design.Id);
                    tenantContext.Load(results);
                    tenantContext.ExecuteQueryRetry();
                    WriteObject(results, true);
                }
            }
        }
Ejemplo n.º 2
0
        //gavdcodeend 37

        //gavdcodebegin 38
        static void SpCsCsomApplySiteDesign(ClientContext spCtx)
        {
            string mySiteUrl = "https://[domain].sharepoint.com/sites/aaa05";
            Guid   myId      = new Guid("abed53c3-4515-4308-8821-ffc3ec3dbcdb");

            Tenant myTenant = new Tenant(spCtx);

            var response = myTenant.ApplySiteDesign(mySiteUrl, myId);

            spCtx.ExecuteQuery();
        }
Ejemplo n.º 3
0
        protected override void ExecuteCmdlet()
        {
            var url       = CurrentWeb.EnsureProperty(w => w.Url);
            var tenantUrl = UrlUtilities.GetTenantAdministrationUrl(ClientContext.Url);

            using (var tenantContext = ClientContext.Clone(tenantUrl))
            {
                var tenant = new Tenant(tenantContext);
                var webUrl = url;
                if (!string.IsNullOrEmpty(WebUrl))
                {
                    try
                    {
                        var uri = new System.Uri(WebUrl);
                        webUrl = WebUrl;
                    }
                    catch
                    {
                        ThrowTerminatingError(new ErrorRecord(new System.Exception("Invalid URL"), "INVALIDURL", ErrorCategory.InvalidArgument, WebUrl));
                    }
                }

                // Retrieve the site designs
                var designs = Identity.GetTenantSiteDesign(tenant);

                if (designs == null || designs.Length == 0)
                {
                    throw new PSArgumentException("No site designs found matching the identity provided through Identity", nameof(Identity));
                }

                foreach (var design in designs)
                {
                    WriteVerbose($"Invoking site design '{design.Title}' ({design.Id})");

                    var results = tenant.ApplySiteDesign(webUrl, design.Id);
                    tenantContext.Load(results);
                    tenantContext.ExecuteQueryRetry();
                    WriteObject(results, true);
                }
            }
        }