You renamed a user in Microsoft 365, but their OneDrive for Business URL still shows the old name. This happens because the OneDrive URL is tied to the original user principal name at the time of site creation. Microsoft 365 does not automatically update the OneDrive site URL when a user is renamed. This article explains why the URL stays the same and provides the exact steps to change it using PowerShell.
Key Takeaways: OneDrive URL After User Rename
- SharePoint Online Management Shell: Required to update the OneDrive URL using the Set-SPOSite cmdlet with the -Url parameter.
- Set-SPOSite -Identity
-Url The core PowerShell command that changes the OneDrive site URL to reflect the new user name.: - User profile sync: After the URL change, the user’s profile picture and other properties may take up to 24 hours to update across Microsoft 365 services.
Why the OneDrive URL Does Not Update After a User Rename
When a user is renamed in the Microsoft 365 admin center, the user principal name and email address change immediately. However, the OneDrive for Business site URL — which follows the pattern https:// — is created at the moment the user first accesses OneDrive. This URL is stored as a SharePoint site collection and is not linked to the user principal name in real time.
Microsoft 365 does not provide a button or setting in the admin center to rename the OneDrive URL after a user rename. The URL change requires a manual operation using PowerShell. The SharePoint Online Management Shell includes the Set-SPOSite cmdlet, which can change the URL of any site collection, including OneDrive sites. Without this step, shared links, file references, and external access to the OneDrive will continue to point to the old URL.
Steps to Change the OneDrive URL After a User Rename
You must run these steps as a SharePoint Online administrator or global admin. The process involves connecting to SharePoint Online via PowerShell, identifying the current OneDrive URL, and then changing it to the new URL that matches the renamed user.
- Install and connect the SharePoint Online Management Shell
Open Windows PowerShell as an administrator. RunInstall-Module -Name Microsoft.Online.SharePoint.PowerShellif the module is not installed. Then runConnect-SPOService -Url https://. Replace-admin.sharepoint.com with your Microsoft 365 tenant name. Sign in with your admin credentials. - Find the current OneDrive URL for the renamed user
RunGet-SPOSite -IncludePersonalSite $true | Where-Object {$_.Owner -eq "user@domain.com"}. Replaceuser@domain.comwith the user’s new email address. The output shows the current OneDrive site URL. Note the full URL, for example:https://contoso-my.sharepoint.com/personal/john_doe_contoso_com. - Verify the user’s new user principal name
In the Microsoft 365 admin center, go to Users > Active users. Select the renamed user and confirm the new user principal name. The new OneDrive URL must match this name. For example, if the new UPN isjohn.smith@contoso.com, the new URL should behttps://contoso-my.sharepoint.com/personal/john_smith_contoso_com. - Change the OneDrive site URL
RunSet-SPOSite -Identity ". Replace" -Url " " with the URL from step 2 andwith the new URL. For example:Set-SPOSite -Identity "https://contoso-my.sharepoint.com/personal/john_doe_contoso_com" -Url "https://contoso-my.sharepoint.com/personal/john_smith_contoso_com". Press Enter. The command runs silently if successful. - Verify the URL change
RunGet-SPOSite -Identity "to confirm the site exists. Then open a browser and navigate to the new URL. The OneDrive site should load with all files and folders intact." - Notify the user to update shortcuts and links
Any file shortcuts or bookmarks that point to the old URL will stop working. Ask the user to replace those links with the new URL. Shared links created before the rename will still work because SharePoint redirects from the old URL to the new one for up to 30 days.
If the OneDrive URL Change Fails or Causes Issues
The Set-SPOSite command returns an error about site lock or provisioning
If the user’s OneDrive site is locked or still provisioning, the URL change will fail. Wait 15 minutes after the user rename and try again. If the site is locked, run Set-SPOSite -Identity " first, then retry the URL change.
Users see a 404 error when accessing the new URL
This usually means the URL change did not complete. Verify that you used the correct tenant name and that the user principal name in the new URL exactly matches the user’s current UPN with underscores replacing periods and the @ symbol replaced with an underscore. For example, john.smith@contoso.com becomes john_smith_contoso_com.
Shared links from before the rename stop working after 30 days
SharePoint automatically redirects old URLs to new ones for 30 days after a URL change. After that, shared links that used the old URL will break. To avoid data loss, ask users to reshare files using the new URL before the 30-day period ends.
OneDrive URL Behavior: Old vs New After User Rename
| Item | Old URL (before PowerShell change) | New URL (after PowerShell change) |
|---|---|---|
| URL pattern | https:// |
https:// |
| File access | Works but shows old user name in address bar | Works with new user name in address bar |
| Shared links created before rename | Redirect to new URL for 30 days | Work immediately |
| Admin center display | Shows old URL under Active sites | Shows new URL under Active sites |
| OneDrive sync client | May show old URL in sync status | Shows new URL after reauthentication |
You can now change a renamed user’s OneDrive URL using the SharePoint Online Management Shell. Run the Set-SPOSite cmdlet with the old and new URLs. After the change, verify the site loads correctly and ask the user to update their shortcuts. For tenants with many renamed users, consider scripting the process with a loop that reads current UPNs from a CSV file.