After a tenant-to-tenant migration, users often find that shared links to files and folders in OneDrive for Business no longer work. These links return errors such as “Access Denied” or “Item not found” because the underlying file IDs and tenant URLs have changed during the migration. This article explains why sharing links break during a cross-tenant migration and provides a step-by-step method to restore them using Microsoft’s native tools and PowerShell scripts.
Key Takeaways: Fixing Broken OneDrive Sharing Links After Tenant Migration
- Microsoft 365 admin center > Settings > Org settings > SharePoint > Sharing: Controls tenant-wide link permissions and expiration policies that affect post-migration behavior.
- SharePoint Online Management Shell + Microsoft Graph PowerShell: Required to bulk-reset sharing links for migrated OneDrive libraries using the
Set-SPOSiteandUpdate-MgDriveItemcmdlets. - OneDrive sync app > Settings > Unlink this PC: Must be run before migration to avoid sync conflicts that can corrupt link metadata.
Why Tenant-to-Tenant Migration Breaks OneDrive Sharing Links
When you move a user’s OneDrive from one tenant to another, the destination tenant assigns a new site ID, new document library ID, and new unique file IDs. Sharing links contain these IDs as part of the URL. For example, a link like https://oldtenant-my.sharepoint.com/personal/user_oldtenant_com/_layouts/15/guestaccess.aspx?share=... includes the old tenant identifier and file GUID. After migration, the file exists at a new URL under the new tenant. The old link points to a location that no longer exists or is owned by a different tenant. Microsoft’s sharing infrastructure does not automatically redirect old links to the new location because the migration is a full content move, not a rename.
Two Types of Broken Links
There are two categories of broken links after a tenant-to-tenant migration:
1. Links shared from OneDrive to external users. These links rely on the old tenant’s guest access token. After migration, the token is invalid because the file no longer resides in the old tenant. External users see an “Access Denied” page.
2. Links shared within the organization across different tenants. If the migration involved splitting a company into two tenants, internal users on the new tenant cannot open links that still reference the old tenant’s site collection. This scenario often occurs during divestitures or mergers.
Steps to Restore Sharing Links After Tenant Migration
The only supported method to fix broken sharing links is to generate new links for the migrated files and communicate the new URLs to all affected users. Microsoft does not provide a direct “remap old link to new file” feature. The following steps use SharePoint Online Management Shell and Microsoft Graph PowerShell to identify and re-create links.
Prerequisites
Before you start, ensure the following:
- You have completed the tenant-to-tenant migration using Microsoft’s Cross-Tenant User Data Migration tool or a third-party migration service.
- You have the SharePoint Online Management Shell installed on a Windows machine.
- You have the Microsoft Graph PowerShell SDK installed and authenticated with the
Files.ReadWrite.AllandSites.ReadWrite.Allscopes. - You have a list of all migrated user OneDrive URLs (e.g.,
https://newtenant-my.sharepoint.com/personal/user_newtenant_com).
Step 1: Identify All Broken Links in a OneDrive Library
- Connect to SharePoint Online
Open SharePoint Online Management Shell as administrator. RunConnect-SPOService -Url https://newtenant-admin.sharepoint.comand sign in with a global admin account. - Retrieve the OneDrive site collection
RunGet-SPOSite -IncludePersonalSite $true -Filter {Url -like "/personal/user_newtenant_com"}to confirm the site exists. - Export all sharing links
Use theGet-SPOSiteSharingLinkcmdlet to list all active sharing links for the OneDrive site. RunGet-SPOSiteSharingLink -Site https://newtenant-my.sharepoint.com/personal/user_newtenant_com | Export-Csv -Path "C:\temp\links.csv". This exports link details including the target file path, link type, and expiration date. - Identify broken links
Open the CSV file in Excel. Filter for links that were created before the migration date. These are the broken links. Note the file paths and the users who own the links.
Step 2: Generate New Sharing Links Using Microsoft Graph
- Connect to Microsoft Graph PowerShell
Open a new PowerShell window. RunConnect-MgGraph -Scopes "Files.ReadWrite.All", "Sites.ReadWrite.All"and sign in with the same admin account. - Get the drive ID for the user’s OneDrive
RunGet-MgUserDrive -UserId user@newtenant.com | Select-Object Id, WebUrl. Note theIdvalue. - Create a new sharing link for each broken file
Use theNew-MgDriveItemLinkcmdlet. For example:New-MgDriveItemLink -DriveId "drive-id" -DriveItemId "item-id" -Type "edit" -Scope "anonymous". Replacedrive-idanditem-idwith the values from the CSV export. The cmdlet returns the new sharing URL. - Log the new URLs
Pipe the output to a CSV file for later distribution:New-MgDriveItemLink ... | Export-Csv -Path "C:\temp\newlinks.csv" -Append.
Step 3: Distribute New Links to Affected Users
- Send an email notification
Use Microsoft Graph to send an email to each user whose OneDrive was migrated. Include the new sharing links and instructions to update bookmarks or re-share the files. - Remove old broken links (optional)
To clean up, runRemove-SPOSiteSharingLink -Site https://newtenant-my.sharepoint.com/personal/user_newtenant_com -SharingLinkId "old-link-id"for each broken link. Obtain theSharingLinkIdfrom the CSV export.
If OneDrive Sharing Links Still Fail After the Fix
External users see “Access Denied” even with new links
This occurs if the new tenant’s external sharing settings are more restrictive than the old tenant. Go to Microsoft 365 admin center > Settings > Org settings > SharePoint > Sharing. Ensure that “Allow sharing to external users and use anonymous access links” is enabled. Also check that the link type you created (e.g., “Anonymous” or “Company-wide”) is allowed by the tenant policy.
Links expire immediately after creation
If the new tenant has a shorter default link expiration policy, newly created links may expire in days instead of years. In the SharePoint Sharing settings, adjust the “Choose expiration and permissions options for sharing links” section. Set a default expiration that matches your organization’s needs, or create links with the -ExpirationDateTime parameter in PowerShell to override the default.
OneDrive sync app shows “This file is shared” but the link is broken
This happens when the sync app cached the old link metadata. Ask the user to run OneDrive sync app > Settings > Unlink this PC, then relink their account. After the sync app re-indexes the files, it will fetch the new sharing metadata from the server.
Old Links vs New Links: Key Differences After Tenant Migration
| Item | Old Link (Pre-Migration) | New Link (Post-Migration) |
|---|---|---|
| Tenant domain | oldtenant-my.sharepoint.com | newtenant-my.sharepoint.com |
| File GUID | Unique to old tenant’s content database | New GUID assigned during migration |
| Guest access token | Issued by old tenant’s Azure AD | Issued by new tenant’s Azure AD |
| Link type (edit/view) | Preserved if migration tool copied permissions | Must be re-created manually or scripted |
| Expiration date | Set by old tenant policy | Set by new tenant policy |
After a tenant-to-tenant migration, you can now identify broken OneDrive sharing links and generate new ones using PowerShell. Next, review your new tenant’s external sharing settings to prevent future link failures. A concrete tip: run a pre-migration script that exports all sharing links to a CSV before the migration starts — this gives you a complete inventory to re-create links faster in the new tenant.