Add support for applying built-in Microsoft site designs (store 1)#5358
Open
fabianhutzli wants to merge 1 commit into
Open
Add support for applying built-in Microsoft site designs (store 1)#5358fabianhutzli wants to merge 1 commit into
fabianhutzli wants to merge 1 commit into
Conversation
The existing Get-PnPSiteDesign and Invoke-PnPSiteDesign cmdlets used CSOM (Tenant.GetSiteDesigns / Tenant.ApplySiteDesign) which only works for tenant-registered custom designs (store 0). Microsoft's built-in site designs such as Event, Department and Human Resources live in the SharePoint site template store (store 1) and require the SiteScriptUtility REST API with a store parameter — there was no way to reach them from PnP PowerShell. - Add Get-PnPSiteDesign -BuiltIn switch: calls SiteScriptUtility.GetSiteDesigns with store 1 and returns BuiltInSiteDesign objects (Id, Title, Template enum) - Add Invoke-PnPSiteDesign -Template <BuiltInSiteTemplates>: resolves the GUID from the existing BuiltInSiteTemplates enum mapping and calls SiteScriptUtility.ApplySiteDesign with store 1 - Add BuiltInSiteDesign model class for deserialising the REST response - Add GetBuiltInSiteDesigns and ApplyBuiltInSiteDesign utility methods to SiteTemplates.cs so the REST logic is centralised - Fix missing DefaultParameterSetName on Get-PnPSiteDesign to prevent ambiguous parameter set error when called without arguments - Update documentation for both cmdlets with new syntax, parameter descriptions and usage examples
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Type
Summary
Adds support for Microsoft's built-in SharePoint site designs (the "store 1" designs) to two existing cmdlets. Previously,
Get-PnPSiteDesignandInvoke-PnPSiteDesignonly worked with tenant-registered custom designs via CSOM. Built-in Microsoft site templates such as Event, Department and Human Resources live in a separate store and can only be reached via theSiteScriptUtilityREST API with"store": 1— making them inaccessible from PnP PowerShell without falling back to rawInvoke-PnPSPRestMethodcalls.Modified cmdlets
Get-PnPSiteDesign-BuiltInswitch (new parameter set). When specified, callsSiteScriptUtility.GetSiteDesignswithstore: 1and returns all built-in Microsoft site designs with theirId,Titleand resolvedTemplateenum value.Invoke-PnPSiteDesign-Template <BuiltInSiteTemplates>parameter (new parameter set). Resolves the GUID from the existingBuiltInSiteTemplatesenum mapping and callsSiteScriptUtility.ApplySiteDesignwithstore: 1.-Identityparameter set (CSOM path for custom designs) is unchanged.Implementation notes
BuiltInSiteTemplatesenum and its GUID mappings inBuiltInSiteTemplateSettingsalready existed in the codebase (used byGet/Set-PnPBuiltInSiteTemplateSettings). The new code reuses these mappings directly rather than introducing any new GUIDs.SiteTemplates.cs:GetBuiltInSiteDesignsandApplyBuiltInSiteDesign. Both POST to theSiteScriptUtilityREST endpoint with"store": 1.BuiltInSiteDesignmodel class was added to deserialise the REST response fromGetSiteDesigns(store 1), which returnsIdandTitlerather than the full CSOMTenantSiteDesignobject.Get-PnPSiteDesignwas missing aDefaultParameterSetName, which would have caused an ambiguous parameter set error when called without arguments after the second parameter set was added. Fixed as part of this PR.