As a SharePoint Administrator, you can confirm OneDrive URLs for specific users in your organization. Whether you’re troubleshooting, provisioning new accounts, or simply ensuring accurate information, understanding the methods to retrieve OneDrive URLs is essential.
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. We recommend you confirm a user's OneDrive URL if you need to specify it.
Note
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
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 deidentified 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.
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 was saved and run:
PS C:\>.\OneDriveSites.ps1
Note
If an error message about being unable to run scripts appears, you'll need to change your execution policies. For more information, see About Execution Policies.
The script prompts you for the SharePoint admin center URL. For example, https://contoso-admin.sharepoint.com is the Contoso SharePoint admin center URL.
When prompted, sign in with your SharePoint Administrator account credentials.
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.
Once you have the URL for a user's OneDrive, you can get more info about it by using the Get-SPOSite cmdlet, and change settings by using the Set-SPOSite cmdlet.
Other methods to retrieve OneDrive URLs
Method 1: Using the Diagnostic Information section in OneDrive settings
As an administrator of the OneDrive site, navigate to the site.
In the upper right-hand corner, select the Settings icon.
Select OneDrive Settings and More Settings.
Under the Diagnostic Information section, copy the OneDrive Web URL.
Method 2: Using PnP PowerShell (Get-PnPUserProfileProperty)
PnP PowerShell is a versatile tool for managing SharePoint and OneDrive. To retrieve the PersonalURL (OneDrive URL) for a user, follow these steps:
Install PnP PowerShell if you haven't already. Run the following command in PowerShell:
Install-Module PnP.PowerShell -Scope CurrentUser
If you need more details on installation, refer to the official PnP PowerShell installation guide.