How to enable SharePoint Spaces in all modern sites

SharePoint Spaces Preview have just arrived, however they are disabled by default and you must enable the feature in any site where you want to build VR environments.  

This can be a tedious process if you want to enable it to all your modern sites, but thanks to PnP PowerShell this process can be easily automated.

sharepoint spaces

The following script gets all Modern sites in your tenant and one by one enables the SharePoint Spaces feature.

To execute the script you must be a global administrator on your tenant and you need to provide the tenant name to establish a connection, once connected sit down and relax the process may take some time depending of the number of sites you have.

Write-Host "Type the tenant name: e.g. Contoso"
$tenantName = Read-Host 
$tenantAdmin = "https://{0}-admin.sharepoint.com" -f $tenantName
$featureID = "2ac9c540-6db4-4155-892c-3273957f1926"

try
{
	Connect-PnPOnline -Url $tenantAdmin -UseWebLogin
} catch {
	Write-Host "Unable to connect."
	exit
}
 
if($modernOnly){
	$Sites = (Get-PnPTenantSite -Template 'GROUP#0') + (Get-PnPTenantSite -Template 'SITEPAGEPUBLISHING#0')
}else{
	$Sites = Get-PnPTenantSite
}
 
Write-Host ("Activating SharePoint Spaces") -BackgroundColor Gray -ForegroundColor Black 
foreach ($Site in $Sites){		
	try
	{
		Write-Host -NoNewline ("* {0} - {1} - " -f $Site.Title, $Site.Url)
		Connect-PnPOnline -Url $Site.Url -UseWebLogin
		Enable-PnPFeature -Identity $featureID -Scope Web
		Write-Host "Done" -BackgroundColor Green
	} catch {
		Write-Host "Fail" -BackgroundColor Red
		exit
	}		
}
 
Write-Host "All Done"

Note: Any modern site created after the script execution will have the SharePoint Spaces feature disabled.

sharepoint spaces powershell
People vector created by freepik – www.freepik.com


2 Responses to “How to enable SharePoint Spaces in all modern sites”

  1. rahul dayal

    May 25, 2020

    HI,

    i run above powershell still i am not able to see webpart. is anything missing.

    Reply
    • João Ferreira

      May 25, 2020

      Hi Rahul,

      Is your tenant EDU? I tried to do it in an EDU tenant and it is not available.

      Reply

Leave a Reply


Web developer focused on SharePoint branding, blogger, tech enthusiast. Travelling and sports are my addictions, knowledge and success are my daily motivations.