Browse Tag

Custom Site Templates

Create SharePoint Subsites with Custom Permissions & Templates Using Powershell

powershell2I had a situation recently in which we were performing a migration from SharePoint Services 2.0 up to SharePoint 2013. When testing the path of copying the sites directly from 2.0 to 2013 they didn’t come across very clean. One of the main reasons was the way permissions was done in 2.0 does not directly match 2013. If we would have performed a migration like this they would have had a working environment but it would have been very hard to manage moving forward. Knowing that we didn’t want to copy the sites we decided to try to create all the new sites prior to the migration and then only copy the content.

When performing our pre-migration analysis we found around 2,000 sites and subsites. We performed multiple information architecture planning workshops to figure out the new site structure for 2013. Once we had the agreed upon new site structure we could then map the sites that needed to be migrated to their new locations. Once we had this kind of data I knew I could automate the creation of all the sites. Now I never like to start my scripts from scratch if I don’t have to and there are a lot of very smart people out there posting helpful info. I found some scripts online and put them together with my own special inserts and use cases. To give the proper credit to where I got this script started.

  • This is a great codeplex solution from @PhillipChilds that will create subsite structure as a CSV. This was a good start but would require me to enter all the information for the SharePoint groups that I needed.
  • I then found this script from @PointBeyond which would create the 3 default SharePoint groups I was looking for.

So now I had a script that would create subsites based on a CSV and create 3 default SharePoint groups if stated, awesome!

My last issue I ran into was the ability to apply a custom site template on the subsite. (here is a list of available site templates in SharePoint 2013 thanks to @vladcatrinescu) When you try to create a subsite using Powershell and pass through a custom site template it will not actually apply the template. The way to get this to work was to apply the site template after the subsite was created. So now all templates being applied whether default or custom will be applied after the site is created. Here is a little trick on how to get a custom site template ID without using Powershell.

I also included the enabling and disabling of a few site features.

  • Minimal Download Strategy will be disabled
  • Getting Started will be disabled
  • Publishing will be enabled

Here is a link to the script and the CSV to get started.

16235-illustration-of-a-green-download-button-pv

There are other areas that I would like to expand on this script but if you have any ideas please let me know!