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
Open SharePoint Online Management Shell.
Connect to SharePoint Online:
Connect-SPOService -Url "https://etr56-admin.sharepoint.com"
- 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"
- 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
}
- 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
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
}
}
}
- 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
- Get sites where a particular site design is applied
$SitesWithXYZSiteDesign = $AllAppliedDesigns | where {$_.SiteDesignID -eq "e76d1988-181f-4911-9f52-1759d5ee9220"}
- 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!