Automate SharePoint Site Creation with PowerShell and Power Automate

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.

Benefits:

  • 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.

Steps to Implement
1. Setup a Power Automate Flow:
     Power Automate will handle workflows triggered during the site creation process.
     Steps to create the flow: 
        1. Go to Power Automate.
        2. Click "New Flow" > "Automated Cloud Flow".

         

        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.
        

         5. Configure the trigger settings.
                a. Under "Who can trigger the flow?" select "Anyone".

                

                b. Add the following Request Body JSON Schema.
            {
                "type": "object",
                    "properties": {
                        "type": {
                            "type": "string"
                         },
                    "properties": {
                        "type": "object",
                        "properties": {
                            "webUrl": {
                                "type": "object",
                                "properties": {
                                      "type": {
                                           "type": "string"
                                        }
                                    }
                              },
                              "parameters": {
                                    "type": "object",
                                    "properties": {
                                        "type": {
                                            "type": "string"
                                          },
                                    "properties": {
                                        "type": "object",
                                        "properties": {
                                            "siteName": {
                                            "type": "object",
                                            "properties": {
                                                "type": {
                                                    "type": "string"
                                                 }
                                              }
                                         },
                                         "product": {
                                            "type": "object",
                                            "properties": {
                                                "type": {
                                                      "type": "string"
                                                }
                                            }
                                          }
                                        }
                                    }
                                }
                            },
                            "webDescription": {
                                "type": "object",
                                "properties": {
                                    "type": {
                                        "type": "string"
                                        }
                                    }
                                 },
                                "creatorName": {
                                    "type": "object",
                                    "properties": {
                                        "type": {
                                            "type": "string"
                                         }
                                      }
                                   },
                                 "creatorEmail": {
                                    "type": "object",
                                    "properties": {
                                        "type": {
                                            "type": "array",
                                            "items": {
                                                "type": "string"
                                            }
                                        }
                                    }
                                 },
                                "createdTimeUTC": {
                                    "type": "object",
                                    "properties": {
                                        "type": {
                                            "type": "string"
                                          }
                                      }
                                  }
                              }
                        }
                 }
             }
        6. Add any additional actions, such as sending an email, creating a list or library, or creating a log.
        7. Save the flow to automatically generate the HTTP POST URL. Copy this URL for use later.
         

         

2. Write a Site Script:
        A site script defines the actions SharePoint will execute when the template is applied.
        Steps to create the script:
            1. Open a text editor (e.g. Notepad++ or Visual Studio Code).
            2. Copy and customize the following JSON structure. 
        $JSONScript =@"
            {
               "$schema": "schema.json",
                "actions": [
                   {
                       "verb": "applyTheme",
                       "themeName": "Custom Theme"
                    },
                   {
                       "verb": "setRegionalSettings",
                       "timeZone": 24,
                       "sortOrder": 25,
                       "hourFormat": "12"
                   },
                  {
                       "verb": "setSiteLogo",
                       "url": "/Style Library/logo.jpg"
                   },
                  {
                       "verb": "createSPList",
                       "listName": "Work",
                       "templateType": 101,
                       "subactions": [
                         {
                           "verb": "setTitle",
                           "title": "Work"
                         }
                     ]
                   },
                  {
                      "verb": "triggerFlow",
                      "url": "PASTE_YOUR_FLOW_URL_HERE",
                      "name": "PowerShell through calling Flow",
                     "parameters": {
                           "siteName": "Demo site",
                           "product": "SharePoint Online"
                       }
                  }
              ],
             "bindata": {},
            "version": 1
          }    
          "@

            3. Replace PAST_YOUR_FLOW_URL_HERE with the URL copied from your Power Automate flow.      

3. Create a site Template using PowerShell: 
     PowerShell allows you to upload and apply the site script to create a template.
      Steps to run the script:
  1. Open PowerShell as an administrator.    
  2. Connect to SharePoint Online.  
    Connect-SPOService –Url https://your-tenant-name-admin.sharepoint.com
  3. Add the site script.
    $JSONScript = Get-Content -Raw -Path “PathTo\SiteScript.json”
    $SiteScript = $JSONScript | Add-SPOSiteScript -Title “Demo Site Script”
  4. Create the site design.
    Add-SPOSiteDesign -Title “Site Template1” -WebTemplate 68 -SiteScripts $SiteScript.ID -Description “Site Template1
  5. Web Template: User 68 for Communication Sites, 64 for Team Sites, or 1 for Team Site without Group.
  6. Disconnect from SharePoint Online.
    Disconnect-SPOService
4. Create a New Site:
        Use the SharePoint Admin Center to create a new site with the custom template.
         Steps to create the site:
            1. Navigation to "https://your-tenant-name-admin.sharepoint.com"
            2. Select Active Sites > Create.
              
            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.

5. Test the Automation:
        1. Open the newly created site.
        2. Verify the following:
                a. The applied theme and regional settings.
                b. The uploaded site logo.
                c. The created SharePoint list.
                d. The triggered Power Automate workflow.          

6. Manage Templates:    
        To remove an existing template:
  1. Reconnect to SharePoint Online in PowerShell. 
    Connect-SPOService -Url https://your-tenant-name-admin.sharepoint.com    
  2. Get the list of site designs.
    Get-SPOSiteDesign

  3. Delete the template by ID.
    Remove-SPOSiteDesign -Identity “TemplateID”
       
Additional Tips for Beginners:

  1. Test Before Deployment: Always test in a development environment.
  2. Error Handling: Enable logging in Power Automate for debugging issues.
  3. Template Naming: Use meaningful full names for scripts and templates to avoid confusion.
  4. 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.

Pros and Cons
Pros
  • Consistent site creation process.
  • Fully customizable based on organization needs.
  • Supports integration with other services.
Cons 
  • Initial setup requires scripting expertise.
  • Debugging errors may require deeper knowledge.
  • Depends on Power Automate flow reliability.
Additional Tips:
  • 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.
Conclusion
Automating SharePoint site creation using PowerShell and Power Automate transforms how you manage site provisioning. This approach enhances efficiency, consistency, and scalability, allowing IT administrators o focus on strategic initiatives. By following this guide, you can create Powerful site templates integrated with workflows that meet your organization's needs.

Elevate Your SharePoint Site Pages with Section Design Ideas: A Simple Guide

Introduction 

SharePoint’s Section Design Ideas makes it easy to create visually appealing site pages. This tool helps you choose images and layouts automatically based on your content, so you do not have to be a design expert to make your pages look great. Follow this guide to see how you can use Section Design Ideas step-by-step to create professional, engaging pages in SharePoint. 

Setting Up Approvals in SharePoint Lists

Setting Up Approvals in SharePoint Lists: A step-by-step Guide 

SharePoint offers a robust out-of-the-box approval workflow for its lists, enabling efficient and controlled document and task management. This blog post will guide you through the process of setting up and utilizing this powerful feature. 

Managing Your Organization’s Brand with the SharePoint Brand Center: A Step-by-Step Guide to Custom Theme and Fonts


In today's digital world, maintaining a consistent brand identity across your organization’s platforms is essential. SharePoint's Brand Center is designed to make this easier by allowing you to manage themes and fonts without writing any custom code. In this guide, we will walk you through how to enable and use the new SharePoint Brand Center, ensuring your SharePoint sites reflect your company’s visual identity. 

 

Introduction 

With the release of the SharePoint Brand Center, Microsoft has made it incredibly simple for organizations to control the look and feel of their SharePoint sites. From custom colors to unique font packages, you can now align your digital workspace with your brand guidelines. This guide will provide you with step-by-step instructions to customize your SharePoint environment. 

  

Step 1: Accessing the SharePoint Admin Center 

To begin setting up your SharePoint Brand Center, you will first need to access the SharePoint Admin Center. Here’s how you can do it: 

    • Open your browser and go to the Microsoft Admin Center: https://admin.microsoft.com  
    • Log in with your admin credentials. 
    • In the top left corner, click the grid of nine dots (app launcher), then select Admin. 

    • Once in the Admin Center, click on Show all from the left-hand menu, then expand the Settings section by clicking on it. 
    • Now, select Org Settings, then click on Brand Center. 

Step 2: Setting up the SharePoint Brand Center Site. 

Once you have navigated to the Brand Center, it’s time to create your Brand Center site. This site will serve as the hub for all your branding needs. 

  • On the Brand Center page (currently in preview), you’ll see options to setup your Site Name and Site Address. These can be named according to your organization’s needs. 
  • If you want to activate the public content delivery network (CDN) for faster access to assets, check the relevant box. 
  • Click on the Create site button to finalize the setup. 

 

  • After a few moments, you’ll receive two important links:         
  • One for the Brand Center site (a communication site that serves as a dashboard for managing your themes and fonts)  
  • Another for the Brand Center app. 

                      
Step 3: Customizing Colors in the Brand Center 

Now that your Brand Center is set up, it’s time to start customizing the colors for your SharePoint sites. 

  • Go to your Brand Center Site and click on the Add Colors button. 
  • Next, click on Add a color. Here, you can either select from a color picker or input a specific hex code to match your company’s brand color. 

    • Assign a name to your color. 
    • Once done, click the Save button. 
    • By adding your custom colors, you ensure that the branding of your SharePoint sites is in line with your organization’s visual guidelines.

Step 4: Creating Custom Themes in SharePoint 

With your colors saved, it’s time to create a custom theme. 

  • Navigate back to the Brand Center and select Themes under the SharePoint section. 
  • Click on Create a Theme and give your theme a relevant name. 
  • On the next screen, you’ll see various UI elements like button, headers, and text boxes that you can customize using the colors you’ve just created. You’ll also be able to preview how these colors will look on SharePoint and Viva Connections. 
  • Once you’re happy with your theme, click on Save. 
                     

Step 5: Applying Your Custom Theme 

Now that your theme is created, you can apply it to your SharePoint sites: 

  • Go to the (Brand Center) SharePoint site and click on the gear icon in the top-right corner. 
  • Select Change the look, then click on Theme. 
  • Under the From your organization section, you’ll see your newly created custom theme. Select it, and your SharePoint site will update to reflect your brand colors. 

            Step 6: Creating Custom Font Packages 

In addition to custom themes, you can also create and apply custom fonts to your SharePoint sites. Here’s how: 

  • Return to the Brand Center and click on Manage your brand. Then, select Add Fonts. 
  • A new window will open where you can upload your custom font files. These files need to be in a supported format like TTF or OTF. 

  • After uploading your fonts, click on Create Font Package. 
  • Assign both a Display Font (used for headers) and a Content Font (used for body text). 

 

  • Click Next, and in the following step, give your font package a name. 

 

  • Click Save to finalize your font package. 

Step 7: Applying Custom Fonts 

    • Once your Custom font package is saved, it’s time to apply it: 
    • Go to the Brand Center SharePoint site where you want to apply the font. 
    • Click on the gear icon and select Change the look, then click on Fonts. 
    • Your custom font will be available under the From your organization section. Select it, and your site will now use the new fonts you uploaded. 

  • Final Step: Once you select the font, the homepage will reflect these changes immediately, showcasing the new typography in headers and body text, ensuring your SharePoint site aligns with your brand’s visual identity.  

       Conclusion 

With the SharePoint Brand Center, managing your organization’s branding has never been easier. By creating custom themes and fonts, you can ensure that all your SharePoint sites align with your company’s visual identity – without needing to write a single line of code. This new feature offers a simple yet powerful way to maintain consistency and professionalism across your organization’s SharePoint environment. 

 

 

Send Emails in SPFx Using SP Utility – The Easy Way!

Overview :   Sending emails is one of the most common functionalities in enterprise-level SharePoint solutions. From notifying users to tri...