Export and Import SharePoint site using Get-PnPSiteTemplate & Invoke-PnPSiteTemplate will not preserve the value of the people/group field

john john Pter 1,325 Reputation points
2025-12-03T00:40:40.66+00:00

I have a SharePoint source site which contain a People/Group field linked to a SharePoint group named "Level2", as follow:-

O9FAtpX1

now i export the site using this powershell:-

Get-PnPSiteTemplate -Out "c:\users\mo\site.xml"

then i created a new site, apply the template using this powershell:-

Invoke-PnPSiteTemplate -Path "c:\users\mo\site.xml"

but on the destination SharePoint site this field will be linked to all users instead of been linked to the related group (Level2), although the Level2 group was imported successfully. any advice, how to preserve this setting?

XWUCuqFc

Thanks

Microsoft 365 and Office | SharePoint | Development
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Q&A Assist
    2025-12-03T00:40:51.7666667+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    When using Get-PnPSiteTemplate and Invoke-PnPSiteTemplate to export and import SharePoint sites, the preservation of the values in People/Group fields can sometimes be problematic. This is due to how these fields are handled during the export and import process. Here are a few suggestions to help you preserve the settings for the People/Group field linked to a SharePoint group:

    1. Check Template Options: Ensure that when you are exporting the site template, you are including all necessary options that pertain to the People/Group fields. Sometimes, specific parameters may need to be set to ensure that group memberships are preserved.
    2. Post-Import Configuration: After importing the site template, you might need to manually set the People/Group field to link to the correct SharePoint group. This can be done using PowerShell scripts that specifically update the field after the template has been applied.
    3. Use PnP PowerShell: Consider using additional PnP PowerShell commands to manage the group memberships directly after the import. Commands like Set-PnPListItem can be useful to update the specific field values after the site template has been applied.
    4. Review Permissions: Ensure that the account you are using has the necessary permissions to modify the People/Group fields and that the group exists in the destination site.
    5. Consult Documentation: Review the official documentation for any updates or notes regarding the handling of People/Group fields during site template operations. There may be specific nuances or known issues documented that could provide further insight.

    By following these steps, you should be able to better manage the preservation of the People/Group field settings when exporting and importing your SharePoint site templates.

    0 comments No comments

  2. Gabriel-N 9,545 Reputation points Microsoft External Staff Moderator
    2025-12-03T08:27:14.37+00:00

    Dear john john Pter

    Thank you for bringing this topic to the Q&A Forum. After conducting tests on my side, I observed the same behavior you described: the import process does not transfer groups from one site to another. This appears to be due to the fact that groups are created within site permissions and cannot be exported or imported between sites.

    To explore a potential workaround, I tested the following approach:

    • Manually create a group with the same settings as the source site.
    • Retrieve the Group ID.
    • Update the UserSelectionScope in the XML file to reflect this Group ID.

    With these steps, the list imported successfully as expected. Based on this, I believe that if we create a group with the desired settings using PowerShell, then obtain its Group ID and update the XML file accordingly, this could serve as a viable workaround worth considering.

    Please note that instead of hardcoding the Group ID in the XML file, we can replace the UserSelectionScope value with a parameter (e.g., UserSelectionScope="{parameter:GroupId}") and pass the actual Group ID when invoking the template. This approach allows us to reuse the same template for different sites without manual edits. I have also tested this method using PowerShell, and the results were successful.

    User's image

    User's image

    Please let me know your thoughts on this approach.


    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread. 


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.