Introduction:
Creating and managing SharePoint sites quickly and easily is important for any organization. By using PowerShell and Power Automate, you can automate site creation and include useful workflows in your site templates. This guide will show you how to create a custom SharePoint site template that makes settings up new sites simple and consistent.
Key Features of This Approach:
- Power Automate Integration: Automatically run workflows whenever a new site is created.
- Custom Site Scripts: Use simple scripts to define how your sites look and work.
- Easy site Management: Set up themes, time zones, and site logos with just a script.
- Workflow Automation: Automatically send notifications or track site creation details using workflows.
- Save Times: Automates repetitive work.
- Keeps Things Consistent: Make sure every new site follows the same setup and rules.
- Scalable: Handles creating lots of sites without manual work.
- Easy to Customize: You can change templates anytime to match your needs.
3. Name the flow (e.g., "PowerShell through calling a Power Automate") and click "Skip".

4. Add the "When an HTTP request is received" trigger.

7. Save the flow to automatically generate the HTTP POST URL. Copy this URL for use later.

3. Replace PAST_YOUR_FLOW_URL_HERE with the URL copied from your Power Automate flow.
- Open PowerShell as an administrator.
- Connect to SharePoint Online. Connect-SPOService –Url https://your-tenant-name-admin.sharepoint.com
- Add the site script.$JSONScript = Get-Content -Raw -Path “PathTo\SiteScript.json”$SiteScript = $JSONScript | Add-SPOSiteScript -Title “Demo Site Script”
- Create the site design.Add-SPOSiteDesign -Title “Site Template1” -WebTemplate 68 -SiteScripts $SiteScript.ID -Description “Site Template1”
- Web Template: User 68 for Communication Sites, 64 for Team Sites, or 1 for Team Site without Group.
- Disconnect from SharePoint Online.Disconnect-SPOService

3. Choose the site type (e.g. Communication site).

4. Under Template, select Your Organization > Your custom template and click on "Use Template".

5. Enter the required site details.
a. Site Name: Provide a site name (e.g. "Demo Communication Site").
b. Site Description: Add a brief description.
c. Site Owner: Specify the owner.

6. Click Create Site and wait for provisioning to complete.
- Test Before Deployment: Always test in a development environment.
- Error Handling: Enable logging in Power Automate for debugging issues.
- Template Naming: Use meaningful full names for scripts and templates to avoid confusion.
- Keep Scripts Modular: Break down complex actions into smaller scripts for easier management.
Advantages: - Automates complex workflows during site creation.
- Centralizes configurations, making maintenance easier.
- Enhances productivity by reducing administrative overhead.
- Automates complex workflows during site creation.
- Centralizes configurations, making maintenance easier.
- Enhances productivity by reducing administrative overhead.
- Consistent site creation process.
- Fully customizable based on organization needs.
- Supports integration with other services.
- Initial setup requires scripting expertise.
- Debugging errors may require deeper knowledge.
- Depends on Power Automate flow reliability.
- Test the JSON Schema and PowerShell Scripts in a development environment before deploying.
- Use descriptive names for site templates to avoid confusion.
- Regularly review and update site scripts to align with organizational changes.