Series: SharePoint Site Provisioning
PowerShell: Updating Site Scripts and Designs
tl;dr: Part of the SharePoint Site Provisioning project, here are some scripts for updating site scripts and designs from PowerShell.
This post begins a series on SharePoint site provisioning, unpacking some of the problems I’ve faced and overcome in building SharePoint site provisioning solutions.
Site scripts and site designs are a great feature of SharePoint. They allow for developing and using templates on SharePoint sites that can do many useful things like:
- Create a list or library
- Apply column or view formatting on a list or library
- Apply a site logo image
There is one annoying limitation, though. These scripts and designed are entirely created through PowerShell. That can make it a pain when you’re testing out a new script and need to update it frequently with each change, especially if you’re handling multiple scripts at once.
So I wrote some PowerShell that handled some basic logic for me:
- Connect to the Microsoft 365 account
- Check if the script already exists
- If yes, update that script reading from the latest file with an incremented version number
- If no, create a new site script
- Check if the site design already exists
- If yes, update that design to include the relevant scripts, with an incremented version number
- If no, create a new design to include the relevant scripts
The code is available on my GitHub account. The current version is minimal, but I may return someday to make some more updates to it like how to automate multiple scripts on the same design.
With this PowerShell script, you only need to tweak it to fit your scheme, and then run the PowerShell each time you need to upload your site script’s changes to your SharePoint tenant. The README file on GitHub provides more detail.
Previous: SharePoint: Desktop Sync Files