Skip to content
This repository has been archived by the owner on Jan 19, 2021. It is now read-only.

Fix for Issue 2473 Add-PnPSiteDesignTask #2542

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion Commands/SiteDesigns/AddSiteDesignTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,26 @@ protected override void ExecuteCmdlet()
ThrowTerminatingError(new ErrorRecord(new System.Exception("Invalid URL"), "INVALIDURL", ErrorCategory.InvalidArgument, WebUrl));
}
}
Tenant.AddSiteDesignTask(tenantContext, webUrl, SiteDesignId.Id);
try
{
var designTask = Tenant.AddSiteDesignTask( tenantContext, webUrl, SiteDesignId.Id );
tenantContext.Load( designTask );
tenantContext.ExecuteQueryRetry();
WriteObject( designTask );
}
catch (System.Net.WebException ex)
{
if (ex.Status == System.Net.WebExceptionStatus.ProtocolError)
{
var webResponse = ex.Response as System.Net.HttpWebResponse;
if (null != webResponse &&
webResponse.StatusCode == System.Net.HttpStatusCode.Forbidden)
{
WriteObject( "The server threw an exception (see below). It seems you may not have access to the server or you are executing this script outside of the tenant admin URL eg. yourtenant-admin.sharepoint.com. Please Connect to the tenant URL first and try again." );
}
}
WriteObject( ex );
}
}
}
}
Expand Down