Copying a Modern SharePoint site 'like for like' using PowerShell | E019
Vložit
- čas přidán 26. 08. 2024
- Saving a site as a template is one of the key features missing in modern SharePoint.
The good news is we can copy a site, 1 for 1 using PowerShell.
This video walks through the process of copying a subsite with all of the lists, libraries, documents, modern pages, web parts, custom columns and everything else using 5 lines of PowerShell script
? Subscribe to SPClassroom SharePoint and o365 videos - www.youtube.co...
SPClassroom is a collection of sharepoint developer tutorials for SharePoint 2013, SP2016, SharePoint Online, office365, and SPFx SharePoint Developer's Framework, with a focus on training videos for Power Users, Developers, and SharePoint Architects.
Find More SharePoint Developer Tutorial, o365 Development Training, and SharePoint Training Videos here:
CZcams: / clardo11
LinkedIn: / deshonclark
Facebook: / spclassroom
Twitter: / spclassroom
Website: spclassroom.com
Snapchat: deshon.clark
Thank you very much! I have spent two days searching for a solution for this. You just save my day. Thanks again.
Awesome! Thanks for watching
You sir, are a legend! Thank-you for making this so easy. Brilliant, cant say thank-you enough
thanks! awesome!
Power automate is faster and easier
Thank you so much for this explanation! No where on the net not even the MS documentation explains it as well as you did! Thank you DeShon! God Bless you!
Glad it was helpful! I really do appreciate the feedback
This is a great video. Thanks for posting Deshon!
Thanks for watching
brilliant as always DeShon, thanks for sharing
Thanks again!
This video is great can you please upload how to do it automatically when we just enter the details and it create the site automatically with the replica of the main site
Thanks fot this very useful video. There is a way to export and import the document library rules ?
This is a very good scenario. I would have thought the rules would have been copied with the library schema. This may be a gap. Have you tested with the latest version of PnP module?
Great Video! Really easy to follow.
thanks Homie! Hope all is well Mark.
This has been incredibly helpful, thank you.
hey Steve, did you figure this out? You may have found the setting in the "config" json. Here are the details on the various options:
docs.microsoft.com/en-us/sharepoint/dev/solution-guidance/configuring-the-pnp-provisioning-engine
@@DeShonClark hi, I did thank you for asking.
I got all of the exports and imports to run but the home page still has the same layout. I know I am missing something but not sure.
Hi DeShon, this has been quite helpful. Is there any additional content/learning resources you can recommend for the JSON config side of things? I have very little knowledge on JSON and struggling on that side of things a little.
You are absolutely correct. Json is critical in this environment and power platform development. Let me see what I can pull together
Could we just create a new the site under SharePoint Admin Center > Active Sites instead of a Subsite?
A very awesome tutorial but still not explain how to export all lists structure and data rows .... Same for SitePages (.aspx) are not exporting with this script
did you figure this one out?
@@DeShonClark I am facing the same issue no data rows and site pages.
another great demo
thanks Abenet, great to see you're back on the channel!
I have created my template.xml from a root site but I cannot apply it to subsites. I did try to create the xml file from the subsite but that fails as well.
Any advice?
Awesome Video, quick question, can this work for copying a another site completely and not a subsite?
i use it to copy site collections, site collections with sub sites, and currently working on hub sites with multiple site collections connected....still working out the kinks for the hub site solution
Hey @Deshon Clark , very useful this session. As you have stated, there is no built in feature for users to replicate SharePoint sites, so this is an excellent workaround for site admins to meet this need. At the end of this video, you mentioned that "in the next video" you were planning to automate the provisioning for these templates using Azure and PA. I looked for this in your video list, but I couldn't find it. Is this something you still plan to present?
I still need to create this....I'm on it
@@DeShonClark Great video. Did you get anywhere with the second part? Cheers
Hi, could you confirm if this is still working as explained? I used this solution back in May/June successfully, trying this process now results in the following: List structures are imported but not list data, Only empty document libraries are imported, no documents imported (No site assets docs nor Shared Document library docs) , Pages are no longer imported either. I think something major has broken in the PnP.Powershell module, I suspect due to a recent update.
Do you get the same outcome when trying this now or is it only me? Thank you!
Hi there! Thank you for reaching out. I apologize for any inconvenience you may be experiencing. As a content creator and CZcamsr, I don't have real-time access to the latest updates or changes in the PnP PowerShell module. Since your comment suggests a potential issue with the module or recent updates, I recommend reaching out to the PnP community or consulting the official documentation for the most up-to-date information regarding the module and its functionality. They will be better equipped to troubleshoot and provide assistance. Thank you for understanding!
Thanks. This was very helpful. You said an automated version of copying a Mod SharePoint site was comming soon? Has that been done? If not is there a way to notify me when it has been done?
thanks for the reminder, check out this 3PV, they are whom I was hinting at. Start with the trial and see if this suits your needs plumsail.com/actions
This was super helpful
thanks Coral!!! That PnP script has always been super helpful. Check out my upcoming video on a different way to automate this via Power Automate with 0 dev skills
Hey, great video! I was wondering how we could configure the .json file to include all the libraries and lists metadata, so that it doesn't appear that my account just recently modified all of these documents, and I am now the author. I would like to copy these lists and libraries but maintain their modified date and modified by information. Thanks!
oh! this is very interesting. There is a way to copy over the lists & libraries and their data, but I'm not 100% if you can maintain the timestamps of the copied data. I will have to look into this one. I did see the option to maintain the author information...but again the timestamp piece is the tricky one. My next video in this updated series will cover the .json config options, and more importantly, the needed config for these different scenarios.
Here's the link to the latest series, it is centered on SharePoint admins, and site templates will be discussed in depth
czcams.com/video/oqXb1ovSZNQ/video.html
Hey DeShon, your videos are great and have been extremely helpful in laying out some pretty complex stuff, nicely done, and thank you!! With these templates, Is it possible to create a site template and update the property bag to change the default content types "document" / "item" to custom ones that live on the HUB?
I'd like for every document library/list in our tenant to use our company defaults, regardless if a list/library is created by an admin or standard user on a given site. I'd like to set this default in addition to other things for an SP site that gets created whether it be from the Admin or creating a new Team and spawning a corresponding site.
hey Alex, sorry for the late reply...this is very interesting and was very common ask back in the day. I am really interested to understand the scenario where you have all list and libraries in the entire tenant conforming to basic schema. I don't think the PnP provisioning script is the right tool for that piece, as it does not address the OOB commands to create sites...so it will always be a chase in that scenario.
In the past, we used event receivers for the site level, that executed a set of commands (associating content types, creating views, adding site columns, etc...to the default document library and creating/updating certain lists).
In modern SharePoint (and even classic SharePoint online), I am not sure of the modern way to pull this off. The #1 concern I would have is disrupting the default structure and how it may break Microsoft's future plans for web parts, site templates, governance, etc...)
Here's one thought...can you add the needed columns to the default documents and list item content types in the HUB? this should push them down to each existing and newly created site collection.
As far as property bag updates, may be create a batch job that updates the new site collections daily...where it is smart enough to distinguish new site collections from the SCs already processed? hopefully this sparks some ideas for you
@@DeShonClark Thank you for the reply and no need to apologize, really appreciate your input and advice! I'm going to contact you through your website and see if I can schedule some time with you to walk through my use case and dive a little deeper! Thank you!
This was awesome! Two questions. 1. Will this work on a Mac? 2. Does this save as an organization site template or automatically apply when a new subsite is created?
Hey, there! This is exactly what I`m looking for. Did you figure a way to do this automatically?
I've never ran PowerShell on MAC before, so not sure how many hoops you would need to jump thru to get it to work. For every new site created, this would need to be ran against it...it will not auto apply to the subsite.
This is a great video Deshon! Will this also move Powerapps forms to the new site?
Thanks for watching... unfortunately...the PowerApps form would not move. This is the biggest sticky point with Power App list forms.
Awesome! That´s helpful!
thanks Eduardo, cannot wait for out session!
Missing an argument for parameter 'Configuration'. Specify a parameter of type 'PnP.PowerShell.Commands.Base.PipeBinds.ExtractConfigurationPipeBind' and try again .. i am getting this error while creating configuration template could you please advise
hmmmm...not sure about this one. did you update the PnP module lately? Did this ever work?
Same issue for me. Impossible to create json file (Missing an argument for parameter 'Configuration'. Specify a parameter of type 'PnP.PowerShell.Commands.Base.PipeBinds.ExtractConfigurationPipeBind' and try again) 🤷
What happens to the sub-site on the Master Site that you created to make the template? Do you delete it after this process? Wait think I answered my own question. The sub-site became the new copied site......DUH! New to sharepoint, will give it a shot though. Thanks
hey John, the subsite created is the new site, as you mentioned, the main template site remains intact and unchanged. Since this video, I've been following the same pattern but with site collections (vs subsites). As the modern SharePoint model is to use more site collections and HUBs to define your site structure. The core concepts are still the same, it is just the site types are different (site collections vs sub sites)
Hi Deshon: Any idea when you'll have time in your busy schedule to produce the video on using Azure for creating a template from a site? You mentioned this near the end of this video on using PnP. Everything you do is much appreciated.
As soon as possible....I will get to this soon, quick hint...it uses the Azure Runbook to execute the same PowerShell we manually execute...also, there is the ability to use an Azure Function....I'll show you both examples so you will have them...more soon.
@@DeShonClark Hi Deshon: That is great to know. Will be checking in periodically to learn how to create templates using Azure Runbook and Azure Function. Thanks again. Appreciate all you do for us
DeShon I finally got this going and it works great! Two things: Is there a way to be able to allow users to select this "Template" from the drop down menu to apply it to a site ? I know that you can do that using sitescripts/sitedesigns but when using that method, the homepage layout and webparts don't apply properly. Using the get-pnpSiteTemplate does though, just curious if you had a good suggestion for something like this. Thank you!
hey Mark, I would have to look into this. But knee-jerk-reaction says, this would require the other sitescripts/sitedesgin configuration as you mentioned. The PnP script is really designed for provisioning, or re-provisioning sites, where as the site design config is more of an inplace (for existing) site scripting, where it creates a copy of the home page, and recreates a new homepage with the new design, as well as update the existing schemas.
Very well done. One quick question, you initially created a subsite before running the script in PowerShell. After the script runs successfully is the new site a 'Team' site or does it remain a 'subsite' in Sharepoint?
Hello, it remains as a subsite within the site collection. The powershell just applies settings to the new site and does not change it's location now site template (definition) type...hope this helps
I'm having trouble with the config.json not working properly for me. I copied the code from the MS site and I also paused your video and copied yours and edited the lists section for my own site and everything seems to be working alright except it isn't persisting site assets
I can't remember, but does site assets have an entry under the list section in the config file. If not, then try adding that entry.
Hello, when I add the -Configuration" , I get the following Error - "Get-PnPSiteTemplate : Missing an argument for parameter 'Configuration'. Specify a parameter of type ..." ?
SAME
SAME @DeShon Clark is there somthing i am missing
Same :-(
Something must have changed with the latest version...let me take a look
Same Issue
Excellent - many thanks. What I have been looking for is a way to build a SharePoint Site, then move it to a client site or many client sites as a template for them to then use. Is this a good process to use for this ?
Awesome! I love this idea. Yes, you can! This process merge two I to one, but they are actually separate process...one to build the template, two, create the site from the template. So you can generate the template from any tenant/site collection and then create sites from that template in any tenant/site collection
@@DeShonClark Excellent. Thanks for letting me know. This has always been a bit if a challenge. My intention was to build out a product (planned this for years but never did it), then sell the application as a template.
@@iainhmunro absolutely!
Another great video Deshon. Quick question? In your video you demo applying to a sub site. I need to clone a site collection Communication site about 25 times. Do I need to create the sites first and then apply the XML? And I assume it works the same for communication sites?
hey Jim...did you get this figured out? You are spot on...have to create the site collections first. There are script options to create the site collection, but I think you need to have Global Admin...or have the PnP global consent in place. I will play around with it and shoot a updated video
Thank you for this. Would you consider this a good strategy for migrating subsites to their own site collection? I'm trying to restructure a heavily nested intranet.
I would not recommend this approach, as this is good for like for like...if you need to "flatten" a site collection to multiple sites under a HUB...then check out ShareGate (their trial is for 15 days, wink wink) or the SharePoint migration tool....but not sure if they support SPO to SPO migrations
@@DeShonClark I can confirm they do support SPO to SPO. I needed to break up a single site that was suffering performance issues and I was having problems with the native move function in SPO, namely its lack of logging. Sharegate has been great.
Thanks for the video, DeShon. Do you have any suggestions for resolving a partial export/import? I get the web part layouts, the quicklinks and people section but no News posts or documents.
Thanks for watching...how do you have the config set-up? Also, are you using the latest PNP module?....sounds like a config setting
@@DeShonClark I have the same question. It was my impression, in watching the video, that if you do not use a json config it would bring over all content from the source site. As a result, I did not use a config and the structure was copied to the new site, but no documents.
Doing this for the first time. I have always used ShareGate or AvePoint for this type of stuff but ShareGate has issue cloning a site collection. I am going to try it out tomorrow in my dev tenant to see if I can figure it out.
Also, you are a very good trainer. I come from a very strong training background in my former life and you are exceptional. Seriously.
DeShon, does this still work for you? It stopped working for me recently with a return error from the invoke PowerShell step that there is a column missing.
I have to check this again...I know pnp changes all the time
@@DeShonClark I had to end up ditching a couple extra doc libraries and lists and it's functioning again. Not sure which site content was the culprit though. 🤔 So I just downscaled for now and I'm back in the game!
Hi DeShon, Im new to PowerShell and this was a great video. Do you have any suggestions for resolving the issue Im getting re: JSON value could not be converted to System.Int32? I followed some other documentation but it hasnt worked.
hey, did you update to the latest version of PnP? I've seen issues with the older version
Does it work if am copying from one tenant to another, I have completed my first powerapps Project using sharepoint as a datasource. I now need to move the sharepoint site, lists from my tenant to that of the client
Will this work?
yes, this works across tenants
hi, @Deshon Clark Is it possiable to create a template that can b selected via the UI for each new site build using this export? as i am using a flat AI and require new sites to be loosely coupled and us a standard design for each fresh site collection.
thanks for watching! yes, this is exactly how I would design it. I would create a Power App form, where the user selects the site type, and in the back end, create the new site collection based on that type (where I would map the site template xml to the site type). Check out this latest video where I describe this exact process using Power Apps and Power Automate czcams.com/video/jwxD-9eSYOE/video.html
Am I going crazy? Where did you get your config.json file from? You didn't run any cmdlet to get it, it just magically appeared!
I got this from the pnp site here: docs.microsoft.com/en-us/sharepoint/dev/solution-guidance/configuring-the-pnp-provisioning-engine
Thank you so much for content, really appreciate it. When i run the connect-PnpOnline i'm getting a "Need Admin Approval" error. I am a SP Admin, do I need extra roles to get connected?
yes, this is something new. They now require Global Admin consent for the PnP PowerShell module...try connecting with the -UseWebLogin switch....that should get around it for now....but you may run into it later if using other features that require it. If possible...best to get the consent now...check out this url on how to create a link to send to the global admin for consent. check out example 3:
pnp.github.io/powershell/cmdlets/Register-PnPManagementShellAccess.html
@@DeShonClark - That's what I figured. Again, really appreciate your videos and content! Keep it up!
Hi Clark can we migrate the content between two different tents.
Hello! Yes, you can migrate content between two different tenants in SharePoint. There are several methods you can use, such as using third-party migration tools or exporting and importing the content manually. Each method has its own steps and considerations, so it would be best to provide more specific information about your scenario. If you have any more questions or need further assistance, let me know!
😍
Hi, fantastic video. I got this error when I ran the import script -
Warning, the source site from which the template was generated had a base template Id value of STS#3, while the current target site has a base template Id value of Group#0. This could cause potential issues when applying the template.
Everything duplicated in the new site so in the Navigation I have 2 Homes, 2 Site Contents, 2 Pages, duplicate sets of Lists etc
Any help much appreciated
Got sorted, all working great.
glad to hear you got it sorted....sounds like configuration. This is a "dream" when it works...takes a few cycles to work out the kinks
Hey, you know where to get the configuration file (json)?
In the video, the speaker mentions that they have the configuration file saved on a second screen that is not visible. They do not provide a direct source for the configuration file. However, they mention that the URL for the JSON schema can be found in the video description. So, you can check the video description for the URL and access the JSON schema for reference.
Hi Deshon, Thanks for a nice video. I tried it with few folders in a document library and also a file in a folder or a document library, it does not create them. It only creates lists and library but not any folders or documents in dcoument library or in a folder. I was wondeing if you have any idea why is that? Thanks again.
Hi there! Thanks for your comment and I'm glad you found the video helpful. In regards to your question, it's possible that there might be a specific configuration or setting that needs to be adjusted for the folders and documents to be included in the site template. Without more specific details, it's difficult for me to provide a solution directly. However, I'll do some further research and testing to see if there are any additional steps or considerations needed for including folders and documents in the template. Once I have more information, I'll be sure to follow up with you. Thanks for bringing this to my attention!
Hi Deshon, once again thanks a lot for your content.
One quick question: Have you encountered any problems while importing custom sharepoint forms to these new sites? I'm having some issues with reference, it's like the new clone sites tricks powerapps into the parent site's form.
I've yet to find a great solution to copy Power App list forms from site to site. Recently at ignite, Microsoft announced the ability to package a Power App List forms with a list template. Can't wait for this to be released. Until then, we have to re-create the form...which is just simply "nasty" and non-scalable.
@@DeShonClark Last week I copied some lists using your tutorial, and in order to copy the powerapps I simply deleted the Sharepoint form connector on the new list and copy-pasted the same thing from the original list. It worked great since all columns were created with the exact same name and data type. Hope it helps!
This was quite helpful. Thank you @Deshon. Quick inquiry, I copied the site template to an existing site and ended up losing the main document library in the previous site. Any way to recover it? Or any script known to reverse this process to get the site back to the previous version? Thanks
Hi there! I'm glad you found the video helpful. I'm sorry to hear about the issue you're experiencing with the site template. Unfortunately, there isn't a built-in way to reverse the process and restore the previous version of the site. Once the site template is applied, it overwrites the existing site's configuration.
To recover the main document library, you would need to restore it from a backup or recreate it manually if you have the necessary files. If you have a backup, you can restore it using SharePoint's restore functionality. If not, you will need to recreate the library and upload the files again.
If you have any more questions or need further assistance, please let me know. I'm here to help!
Thank you so much for this video DeShon, when I include tenant handler in my config.json file it does not include it to my template. Do you have any insight as to why that is happening ?
Hey man thanks for watching, that's weird not 100% on why pieces are being missed. Quick question, what type of site is the source site? Which handler was included and missing data.
@@DeShonClarkits a team site without MS-group. The only handler I'm missing is the Tenant Handler. I'm trying to use it to create subsite but it seems to skip it entirely when generating the template. I know you didn't include the Tenant hander in your video tho
Actually, don't think you need a handler for this. try removing the tenant handler and re-run. I want to say the subsites come automatically. I actually had to configure NOT to include them in one usecase...keep me posted
😮😮 Wow... This works great. Now... how can this all be integrated into PowerAutomate?! 🤣🤣
Great question! Integration with Power Automate is definitely possible and can make the process even more seamless. In the next video, we will cover how to execute the PowerShell script using an Azure function and automate the process using Power Automate.
By utilizing Power Automate, you can trigger the site provisioning process based on certain events, such as the submission of a form or the creation of a new entry in a SharePoint list. This allows for a fully automated provisioning process without any human interaction.
Stay tuned for the next video where we will dive into the Power Automate integration. If you have any more questions, please feel free to ask!
@@DeShonClark That's exactly my use case! Looking forward to it. Thank you. 💙
Hi,
Great tutorial but I think I am missing something here because when I tried the script it was not adding data rows in xml file, any idea sir?
Hi! I'm glad you found the tutorial helpful. It's possible that there may be an issue with the script or the configuration. Without more specific details or seeing your code, it's difficult to pinpoint exactly what the problem could be. I recommend double-checking your code for any errors or missing syntax. If you're still experiencing issues, feel free to reach out and I'll do my best to assist you.
Hi Deshon! I started our SP hub project a month or so ago and am jumping bck in to finish it now. Your videos are brilliant. They have helped me immensely! I am having hard time finding the videos leading up to this one which is EO19. Did they get archived?
thank you for watching...my sequence is all over the place, a bunch of start and stop series. I am in the process of cleaning this up. Which topic are you looking for?
ok I think i get what you did. did you create a basic site and then export that config to create the JSON file?
Hi Deshon, in the creating the subsite, if I want to copy the exactly the same site and the permission, can we do the same way as you do? as my case is that our customer just want to clone the site by year, so it needs to be the same content, libraries, permission in every year, but they still can change the permission after that. Thank you very much for your help, I greatly appreciate that!
Hey there! Yes, you can definitely use the same process to clone a site with the same content, libraries, and permissions every year. The PowerShell script I showed in the video allows you to export the site template, including all the content and configuration, and then import it into a new site. This will give you a one-to-one mirror image of the original site.
However, keep in mind that the permissions you set during the template creation will be replicated as well. So if you want the cloned site to have the same permissions as the original site, you should make sure to set the appropriate permissions before exporting the template.
Once the cloned site is created, the site owner or administrator can still modify the permissions as needed. Let me know if you have any other questions!
Hey! Great video, it was really helpful. I tried running the same commands but I got this error, can you help me fix it?
Get-PnPSiteTemplate : Server relative urls must start with SPWeb.ServerRelativeUrl
At line:31 char:6
+ Get-PnPSiteTemplate -Out $exportTemplatePath -IncludeAllClientSi ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Get-PnPSiteTemplate], PSInvalidOperationException
+ FullyQualifiedErrorId : InvalidOperation,PnP.PowerShell.Commands.Provisioning.Site.GetSiteTemplate
Hey there! I'm glad you found the video helpful. It looks like the error you encountered is related to the server-relative URLs not being correctly specified. Specifically, the error message mentions that the server-relative URLs should start with SPWeb.ServerRelativeUrl.
To troubleshoot this issue, make sure that the URL you provided for the site in the script starts with the server-relative URL (e.g., "/sites/YourSite") instead of the absolute URL (e.g., "YourSite.sharepoint.com/sites/YourSite").
If you're still having trouble, please let me know the specific command you're trying to run, and I'll do my best to assist you further.