Symptoms
When attempting to migrate a Web Part, ShareGate Migrate 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 Migrate 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
Solutions
Migration to a 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.
Migration to a modern site
Without SharePoint admin or Global admin permissions, the Custom Script feature cannot be activated automatically in a modern site during the migration. Because of this, ShareGate Migrate is not able to migrate the forms, web parts, and ASPX pages.
For more information on custom script see the Microsoft article Allow or prevent custom script.
Note: Custom Script is disabled in a modern site when it is created in SharePoint, even if you have it enabled at the tenant level.
Use SharePoint admin or Global admin permissions
If you use SharePoint admin or Global admin permissions, the app will be able to activate custom script automatically during the migration.
If you have site collection admin permissions, you can ask a SharePoint admin or global admin to activate custom script on your site collection manually with the steps below.
Activate custom script manually in Microsoft 365
To activate custom script in a Microsoft 365 site collection with PowerShell, follow these steps:
- 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.
Note: It is recommended to 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".
Activate custom script manually in SharePoint 2019
To activate custom script in a SharePoint 2019 site collection with PowerShell, follow these steps:
- 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 = [Microsoft.SharePoint.SPBasePermissions]::EmptyMask\
Run your migration again, and everything should be working properly.