View the list of OneDrive URLs for users in your organization
This article is for global and SharePoint admins in Microsoft 365 who want to confirm the OneDrive URLs for users in their organization.
About OneDrive URLs
The URL for a user's OneDrive is usually in the following format:
https://<tenant name>-my.sharepoint.com/personal/<user principal name>. For the user principal name (UPN), any special characters such as a period, comma, space, and the at sign ("@") are converted to underscores ("_"). See the following table for examples.
Numbers or GUIDs might be appended to the URL if a conflict is detected, so it's always best to confirm a user's OneDrive URL if you need to specify it.
Unless OneDrive accounts are pre-provisioned, the URL isn't created until a user accesses their OneDrive for the first time.
Also, the OneDrive URL will automatically change if the user's UPN changes. For example, if the user changes their name or the domain name changes for a rebranding or business restructuring.
Use the OneDrive usage report to view the list of OneDrive users and URLs
Go to the OneDrive usage report in the Microsoft 365 admin center and sign in as a SharePoint admin, global admin, global reader, or reports reader. (If you see a message that you don't have permission to access the page, you don't have one of these roles in your organization.)
If you have Office 365 operated by 21Vianet (China), sign in to the Microsoft 365 admin center, browse to Reports > Usage. Under OneDrive files, select View more.
Scroll to the table below the charts.
If you see GUIDs in the table instead of URLs and names, go to the Reports setting and clear the box In all reports, display de-identified names for users, groups, and sites.
You can copy individual OneDrive URLs from the URL column. For easier searching and copying, export the table as a .csv file. In the upper left of the table, select Export.
Use PowerShell to create a list of all the OneDrive URLs in your organization
The list you create in these steps will be saved to a text file.
If you installed a previous version of the SharePoint Online Management Shell, go to Add or remove programs and uninstall "SharePoint Online Management Shell."
Save the following text to a PowerShell file. For example, you could save it to a file named OneDriveSites.ps1.
$TenantUrl = Read-Host "Enter the SharePoint admin center URL" $LogFile = [Environment]::GetFolderPath("Desktop") + "\OneDriveSites.log" Connect-SPOService -Url $TenantUrl Get-SPOSite -IncludePersonalSite $true -Limit all -Filter "Url -like '-my.sharepoint.com/personal/'" | Select -ExpandProperty Url | Out-File $LogFile -Force Write-Host "Done! File saved as $($LogFile)."
Open the SharePoint Online Management Shell. Navigate to the directory where the script has been saved and run:
If you get an error message about being unable to run scripts, you might need to change your execution policies. For info, see About Execution Policies.
The script will prompt you for the SharePoint admin center URL. For example,
https://contoso-admin.sharepoint.comis the Contoso SharePoint admin center URL.
You will then be prompted to sign in. Use a SharePoint admin or global admin account.
After the script successfully completes, a text file is created in the location specified by the $LogFile variable in the script. This file contains a list of all OneDrive URLs in your organization. The following text provides an example of how the list of URLs in this file should be formatted.