Get OneDrive Site URLs for Users Using PowerShell

Get OneDrive Site URLs for Users Using PowerShell

Do you need to compile a list of all your organization’s OneDrive site URLs for users? This can be helpful for administrative tasks, permissions management, or user migration projects. Fear not, this blog will equip you with several methods to retrieve the list of OneDrive URLs for users in the organization. Whether you’re dealing with a single user in distress or need to access a comprehensive list of URLs, we’ve got you covered!

Shortened URLs for OneDrive Web

Firstly, let’s understand the format of OneDrive URLs. A user’s OneDrive URL typically follows the format: https://<tenant name><user principal name>

If you visit OneDrive web currently, you will see the URL formatted like this: https://<tenant name>

Now, Microsoft is shortening OneDrive for Business web URLs to simplify navigation. The rollout will begin in mid-June 2024 and is expected to be completed by mid-July 2024.

The new URLs of OneDrive web will have: https://<tenant name>

This change applies not only to the main OneDrive view but also to specific sections like Home, My Files, and Favorites.

Note: This is a seamless change. You’ll still be able to access files, share links, and browse other users’ OneDrive just as before. Existing links, bookmarks, and automated processes will continue to work flawlessly.

View the List of OneDrive URLs for Users Using OneDrive Usage Report

To get the list of OneDrive for Business URLs for all users, sign-in to Microsoft 365 admin center with your SharePoint administrator, global reader, or reports reader account.

  1. Navigate to Reports –> Usage –> OneDrive Usage Report
  2. Click on Usage next to ‘Activity’ slider.
  3. Export the table as a CSV file for easier searching and copying.

OneDrive Site URLs

If you see GUIDs instead of URLs, go to the Reports setting and clear the “Display concealed user, group…” checkbox. By doing so, identifiable names in Microsoft 365 usage reports will be displayed.

Note: If the Site URL is missing in OneDrive usage report, you may need to be patient. Microsoft is aware of the issue and is working on a resolution. However, due to the operation’s complexity, they indicated that it may take a long time to fix.

Find OneDrive URLs for Users with PowerShell

To get the OneDrive site URLs for users using PowerShell, find the methods mentioned below.

Get OneDrive Site URLs and Size Report Using PowerShell

To bypass the waiting time and need for manual navigation, we have developed a user-friendly script to export OneDrive site URLs and size report. This script simplifies the process, saving you time and effort.

Make sure to connect to the latest SharePoint Online Management PowerShell before running the script.

Download Script: GetOneDriveSiteURLs.ps1

Script Highlights:

  • The script fetches the OneDrive URLs and storage usage.
  • Exports report results into CSV format for easy access and analysis.
  • The script is scheduler friendly. I.e., You can pass the credential as parameters instead of saving inside the script.

Script Execution:

To run this script, you can choose any one of the methods below.

Method 1: Execute the script with MFA/non-MFA accounts.


Upon execution, you will be prompted to enter your SharePoint organization name. Once provided, the script will download the OneDrive site URLs for the specified tenant.

Method 2: Execute the script by explicitly mentioning credentials.

./GetOneDriveSiteUrls.ps1 -UserName [email protected] -Password XXX 

Also, you can use the above format to run a PowerShell script from Task Scheduler. If the admin account has MFA, then you need to disable MFA based on the Conditional Access policy.

Sample Output:

The exported report contains the following attributes:

  • OneDrive Url
  • Owner UPN
  • Storage Used Size (MB)
  • Storage Quota (MB)
  • Last Content Modified Date

Note – When you change the ownership of a specific site, the new owner’s name will be displayed as the Owner UPN. In such cases, the site name and the owner’s name will not match.

Here’s an example of sample output.

OneDrive URLs and Size

Get OneDrive URL for Specific User Using PnP PowerShell

SharePoint Patterns and Practices (PnP) PowerShell is a set of cmdlets designed to automate and simplify common SharePoint and OneDrive tasks. Before proceeding further, connect to SharePoint Online Using PnP PowerShell.

Run the following cmdlet to retrieve the OneDrive site URL for specific user.

Get-PnPUserProfileProperty -Account [email protected] | Select-Object -ExpandProperty PersonalUrl 

The above code will fetch Harvey’s OneDrive site URL.

By understanding the different methods outlined in this blog post, you can efficiently retrieve OneDrive URLs for your users in a SharePoint environment. This empowers you to manage user access, troubleshoot issues, and ensure accurate access to cloud storage.

Get OneDrive URL for an Individual User Using MS Graph PowerShell

You can also use Microsoft Graph PowerShell to access OneDrive and other Microsoft 365 services. Firstly connect to Microsoft Graph PowerShell with “Directory.ReadWrite.All”, “Sites.ReadWrite.All”, “Files.ReadWrite.All” permission scope to retrieve OneDrive URL for a Microsoft 365 user.

Then, execute the following code to get the OneDrive URL for a specific user.

$userPrincipalName = "[email protected]" 

$userObject = Get-MgUser -Filter "userPrincipalName eq '$userPrincipalName'" 

$userOneDrive = Get-MgUserDefaultDrive -UserId $ 

$oneDriveWebUrl = $userOneDrive.webUrl 

Write-Host "OneDrive WebURL for ${userPrincipalName}: $oneDriveWebUrl" 

In the provided script, you should replace the placeholder email address [email protected] with the actual user principal name (email address) of the user whose OneDrive URL you want to retrieve.

To gain OneDrive URL for specified set of users, run the following.

$users = @("[email protected]", "[email protected]", "[email protected]") 

 foreach ($user in $users) { 

  $userPrincipalName = $user 

  $userObject = Get-MgUser -Filter "userPrincipalName eq '$userPrincipalName'" 

   if ($userObject) { 

    $userOneDrive = Get-MgUserDefaultDrive -UserId $ 

    $oneDriveWebUrl = $userOneDrive.webUrl 

    Write-Host "OneDrive WebURL for ${userPrincipalName}: $oneDriveWebUrl" 

  } else { 

    Write-Host "User not found: $userPrincipalName" 



Choosing the Right Method

The best method depends on your needs and technical expertise:

  • The OneDrive Usage Report is a user-friendly option for a quick overview.
  • The PowerShell script is ideal for creating a comprehensive list of all OneDrive URLs.
  • PnP PowerShell and Microsoft Graph PowerShell are suited for advanced users comfortable with scripting and programmatic access.

By leveraging these methods, you can efficiently manage OneDrive URLs within your organization, ensuring smooth user access and data management!

Get OneDrive Site URLs for Users Using PowerShell

by Praba time to read: 4 min