Share via


SharePoint Online site designs: Verify what site designs are applied where

Site designs

If you are new to site designs, have a look at this PnP Webcast where Vesa Juvonen and Erwin van Hunen introduce SharePoint Site Designs and Site Scripts:
View

On Microsoft Docs you can find all site design and site script Powershell cmdlets this article refers to. 

Scenario

You have been happily applying site designs on your sites. Perhaps initially it was an organized action, with a proper inventory, but with time some corrections had to be applied, some modifications; some extra site scripts may have been added by overzealous and overpowered users and now it's a mess where noone knows what is what. 

What you need is to know what site designs were applied where.

Solution

  1. Open SharePoint Online Management Shell.

  2. Connect to SharePoint Online:

Connect-SPOService -Url "https://etr56-admin.sharepoint.com"
  1. Choose the sites which you want to scan for site designs, e.g.
  • if you want to check all sites on the tenant
$AllSites = Get-SPOSite -Limit All
  • if you want to get sites fulfilling certain condition
$AllSites = Get-SPOSite -Limit All | where {$_.Owner -eq "arleta@test.com"}
  • if you have pre-selected sites in a csv
$AllSites = Import-Csv "PathtoCSV"
  1. Get the site design runs for every site. Mind that the fact that a site design has been applied to a site does not always mean that all features within the site design are present on that site. They might have been skipped due to incompatibility, errors or overwritten by site scripts applied later or user actions.
$AllSites | Foreach-Object{
    $siteDesignRuns = Get-SPOSiteDesignRun -WebUrl $_.Url
    
 
 
}
  1. Additional lines to see the script as it progresses. Not necessary for script execution. Consider using Write-Progress or Write-Verbose for a production script:
if($siteDesignRuns){
        Write-Host $_.Url -ForegroundColor Green
        Write-Host $siteDesignRuns.Count
        Write-Host $siteDesignRuns.sitedesignid
  1. There are several properties available:

 but we need only ID to identify the site design.
 

$AllSites | Foreach-Object{
    $siteDesignRuns = Get-SPOSiteDesignRun -WebUrl $_.Url
     
    if($siteDesignRuns){
        Write-Host $_.Url -ForegroundColor Green
        Write-Host $siteDesignRuns.Count
        Write-Host $siteDesignRuns.sitedesignid
 
        foreach($siteDesign in $siteDesignRuns)
        {
             
            $SingleAppliedDesign = New-Object PSObject -Property @{
                SiteDesignID       = $siteDesign.SiteDesignID
                SiteUrl             = $_.Url
            }
 
            $AllAppliedDesigns+=$SingleAppliedDesign
        }
    }
}
  1. Now in $AllAppliedDesigns we have got all the sites with matching site design IDs that were applied to them. Sort them to view what SharePoint Online site designs were applied where.
Write-host $AllAppliedDesigns.count
 
$AllAppliedDesigns | sort SiteDesignID
  1. Get sites where a particular site design is applied
$SitesWithXYZSiteDesign = $AllAppliedDesigns | where {$_.SiteDesignID -eq "e76d1988-181f-4911-9f52-1759d5ee9220"}
  1. Export them to CSV.
$SitesWithXYZSiteDesign | Export-CSV c:\PathToCSV.csv

Full script

import-module microsoft.online.sharepoint.powershell
 
#Connect-SPOService -Url https://etr56-admin.sharepoint.com
 
$AllSites = Get-SPOSite -Limit All
 
$AllAppliedDesigns = @()
 
$AllSites | Foreach-Object{
    $siteDesignRuns = Get-SPOSiteDesignRun -WebUrl $_.Url
     
    if($siteDesignRuns){
        Write-Host $_.Url -ForegroundColor Green
        Write-Host $siteDesignRuns.Count
        Write-Host $siteDesignRuns.sitedesignid
 
        foreach($siteDesign in $siteDesignRuns)
        {
             
            $SingleAppliedDesign = New-Object PSObject -Property @{
                SiteDesignID       = $siteDesign.SiteDesignID
                SiteUrl             = $_.Url
            }
 
            $AllAppliedDesigns+=$SingleAppliedDesign
        }
    }
}
 
Write-host $AllAppliedDesigns.count
 
$AllAppliedDesigns | sort SiteDesignID

$SitesWithXYZSiteDesign = $AllAppliedDesigns | where {$_.SiteDesignID -eq "e76d1988-181f-4911-9f52-1759d5ee9220"}

Downloads

Comments? Questions? Have a look at my GitHub repo, where you can find this SharePoint Online script and many others!

The script

My GitHub @ PowershellScripts