- Create Base Site Script JSON
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/site-design-script-actions.schema.json",
"version": 1,
"actions": [
{
"verb": "createSPList",
"listName": "Matter Details",
"templateType": 100,
"subactions": [
{
"verb": "setTitle",
"title": "Matter Details"
},
{
"verb": "addSPField",
"fieldType": "Text",
"displayName": "Matter Number",
"internalName": "matterNumber",
"isRequired": true,
"addToDefaultView": true
},
{
"verb": "addSPField",
"fieldType": "Text",
"displayName": "Client Name",
"internalName": "clientName",
"isRequired": true,
"addToDefaultView": true
},
{
"verb": "addSPField",
"fieldType": "User",
"displayName": "Responsible Attorney",
"internalName": "responsibleAttorney",
"isRequired": true,
"addToDefaultView": true
},
{
"verb": "addSPField",
"fieldType": "Choice",
"displayName": "Matter Status",
"internalName": "matterStatus",
"choices": ["Active", "Pending", "Closed"],
"addToDefaultView": true
}
]
},
{
"verb": "createSPList",
"listName": "Key Dates",
"templateType": 100,
"subactions": [
{
"verb": "setTitle",
"title": "Key Dates"
},
{
"verb": "addSPField",
"fieldType": "DateTime",
"displayName": "Deadline",
"internalName": "deadline",
"isRequired": true,
"addToDefaultView": true
}
]
},
{
"verb": "createDocumentLibrary",
"libraryName": "Matter Documents",
"subactions": [
{
"verb": "addContentType",
"name": "Legal Document"
}
]
},
{
"verb": "setSiteExternalSharingCapability",
"capability": "Disabled"
},
{
"verb": "triggerFlow",
"flowId": "",
"name": "Matter Site Provisioning Flow"
}
]
}
- Deploy Site Script Using PowerShell
# Connect to SharePoint Online
Connect-SPOService -Url "https://yourtenant-admin.sharepoint.com"
# Add the site script
$siteScript = Get-Content -Path "matter-site-script.json" -Raw
$scriptResult = Add-SPOSiteScript -Title "Matter Management Script" -Content $siteScript
# Create site design
Add-SPOSiteDesign `
-Title "Matter Management Site" `
-WebTemplate "64" `
-SiteScripts $scriptResult.Id `
-Description "Template for new legal matters"
-
Create Power Automate Flow for Site Provisioning
- Trigger: When a new item is created in a master matters list
- Actions:
1. Create site using site design 2. Update site properties 3. Configure additional permissions 4. Update master tracking list with new site URL
-
Create Hub Site Configuration
- Register main site as hub site using PowerShell:
Register-SPOHubSite -Site "https://yourtenant.sharepoint.com/sites/LegalHub"
- Associate matter sites with hub automatically in flow
- Register main site as hub site using PowerShell:
- Create Power Apps Form
# Grant permissions to Power Apps
Grant-SPOSiteDesignRights `
-Identity $siteDesign.Id `
-PrincipalNames "[email protected]" `
-Rights View
- Power Apps Component
- Form fields:
- Matter Number (auto-generated)
- Client Name
- Matter Description
- Practice Area
- Responsible Attorney
- Integration with Power Automate flow
- Embedded in SharePoint page
- Form fields:
- Add Theme
{
"verb": "applyTheme",
"themeName": "Legal Matter Theme"
}
- Navigation Setup
{
"verb": "navigation",
"navigation": [
{
"displayName": "Home",
"url": "~site/SitePages/Home.aspx"
},
{
"displayName": "Matter Documents",
"url": "~site/Matter Documents"
}
]
}
- Apply Site Design to Existing Sites
# Get site design ID
$siteDesignId = (Get-SPOSiteDesign | Where-Object {$_.Title -eq "Matter Management Site"}).Id
# Apply to specific site
Invoke-SPOSiteDesign `
-Identity $siteDesignId `
-WebUrl "https://yourtenant.sharepoint.com/sites/Matter123"
- Monitor Site Design Application
# Get site design runs
Get-SPOSiteDesignRun `
-WebUrl "https://yourtenant.sharepoint.com/sites/Matter123"
-
Version Control
- Maintain site scripts in source control
- Document all changes
- Test in development tenant first
-
Security
- Use PnP PowerShell for sensitive operations
- Implement least-privilege access
- Regular security reviews
-
Maintenance
- Regular script updates
- Monitor site design success rates
- Regular backup of scripts and configurations
-
Performance
- Limit number of actions in single script
- Use batch operations where possible
- Monitor flow execution times