Symptoms
You migrate to a site in Microsoft 365 with Copy content only, and you receive the following warning message on a library:
Copying files that potentially include script requires enabling custom script setting at the destination.
You also receive the following error message on some of your files:
Enable custom script setting at the destination to copy X files.
Error codes
AN-138-459
DA-177-459
Index
Details
Without custom script enabled on your site collection, Microsoft 365 does not allow ShareGate Migrate to upload files that could potentially contain custom scripts if the custom script feature is not activated.
You will find a warning on the library and an error on each file that could not be copied. To copy these files with Copy content only, you will need to activate custom script on your destination site manually.
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 created in SharePoint, even if you have it enabled at the tenant level.
Solution
ShareGate Migrate cannot automatically change the custom script setting when you copy files to a modern site with Copy content only. A SharePoint admin or global admin will have to activate the setting manually.
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
Rerun your migration, and everything should be working correctly.
Note: It is recommended to set Custom Script back to denied after the migration. To do so, you can rerun the script, but this time change the -DenyAddAndCustomizePages value to "1".