Symptoms
When attempting to migrate a Web Part, Sharegate displays the following message :
Unable to create or update WebPart. In Microsoft 365, this is mainly caused by the farm setting "Custom Script" being deactivated.
Index
Error Code
- WP-027-076
- DA-165-076
Details
There is a setting called Custom Script in Microsoft 365 which allows the administrator to choose whether custom scripts are enabled or disabled on a site.
Since web parts function as custom scripts, Sharegate will not be able to migrate web parts if custom scripts are disabled.
Note: Custom scripting capabilities are disabled by default for:
- Personal sites
- Self-service created sites
- The Root Site Collection of the Tenant
Solution
Classic Site
You must enable custom scripts in your settings and retry the migration.
To enable custom scripts:
- Sign in to Microsoft 365
- Click the app launcher icon
- Click Admin
- Select Settings
- Under Custom Script select:
- Allow users to run custom script on personal sites.
- Allow users to run custom script on self-service created sites.
- Click OK
- It takes 24 hours for changes to this setting to take effect.
- For more on custom scripts, click here.
Modern site
The Custom Script feature can't be activated automatically in a modern site during the migration. Because of this, Sharegate is not able to migrate the forms, web parts, and ASPX pages. Learn more.
Note: Custom Script is disabled in a modern site when it's created in SharePoint, even if you have it enabled at the tenant level.
Microsoft 365
To resolve this in Microsoft 365, you'll need to follow the steps below to activate custom scripting using PowerShell:
- Download the Sharepoint Online Management Shell.
- Open a Sharepoint Online Management Shell prompt.
- Run the two following commands:
Connect-SPOService -Url https://YourDomain-admin.sharepoint.com Set-SPOSite -Identity https://YourDomain.sharepoint.com/sites/YourSite -DenyAddAndCustomizePages 0
Run your migration again, and everything should be working properly.
You should set Custom Script back to denied after the migration. To do so, you can run the script again, but this time change the -DenyAddAndCustomizePages value to "1".
SharePoint 2019
To resolve this in SharePoint 2019, you will need to follow the steps below to activate custom scripting using PowerShell:
- Open a Windows PowerShell or Windows PowerShell ISE window.
- Run the following script on your Site Collection:
$site = Get-SPSite -Identity "http://yourfarm/sites/yoursite"
$site.DenyPermissionsMask = $site.DenyPermissionsMask -bxor [Microsoft.SharePoint.SPBasePermissions]::AddAndCustomizePages
Run your migration again, and everything should be working properly.