Symptoms
When migrating to Microsoft 365 Groups or publishing sites in Microsoft 365, you receive this error message:
Copying to a Microsoft 365 Site Collection requires Custom Scripts to be enabled at the destination. This setting will be modified prior to the migration.
Index
Error Code
AN-122-313
IN-803-002
DA-140-325
Details
Custom scripts are automatically enabled when running a migration in Microsoft 365 as a Global Administrator. If you do not run the migration as a Global Administrator, SharePoint cannot automatically enable custom scripts.
Note: It is possible custom scripts become enabled during other actions as well. You can always verify the setting though your Admin Center.
Solution
Classic Sites
Run the migration as a Global Administrator so that no manual action is required on your part to enable custom scripts.
If you cannot run your migration as a Global Administrator, you must manually enable custom scripts by following the instructions in this article.
Modern Sites
The Custom Script feature cannot be activated automatically in a modern site during the migration. Because of this, ShareGate Desktop 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.