Skip to main content
All CollectionsMigrateHelp me solve thisMigration Errors
Copying to a Microsoft 365 Site Collection requires Custom Scripts to be enabled at the destination
Copying to a Microsoft 365 Site Collection requires Custom Scripts to be enabled at the destination
Updated this week

Symptoms

You migrate to a modern SharePoint site, publishing site, or team in Microsoft 365, and you receive this warning 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.

Error code

  • AN-122-313

  • IN-803-002

  • DA-140-325

Index

Details

Without custom script enabled on your site collection, ShareGate Migrate is not able to migrate your forms, web parts, and ASPX pages.

The message appears to warn you that ShareGate Migrate made an attempt to activate custom script on your destination site.

Without SharePoint admin or Global admin permissions, the Custom Script feature cannot be activated automatically in a modern site during the migration. This means that you could also have errors related to the failure to activate custom script.

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.

Solution - Classic site

Run the migration as a global admin or SharePoint admin so that no manual action is required on your part to enable custom script.

If you cannot run your migration as a global admin or SharePoint admin, you must manually enable custom script by following the instructions in this Microsoft article.

Solution - Modern site

If you do not have global admin or SharePoint admin permissions, ShareGate Migrate cannot activate custom script automatically in your modern site during a migration.

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:

  1. Open a SharePoint Online Management Shell prompt.

  2. 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:

  1. Open a Windows PowerShell or Windows PowerShell ISE window.

  2. 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.

Change your copy options

If you are unable to use PowerShell to enable custom script, you can run your migration without migrating content that impacts the modern experience.

  1. From the migration screen, click Options.

  2. Under Configurations, deselect Web parts and Customized list forms.

Note: You will still get this warning in your migration report when you migrate to a modern site.

Did this answer your question?