logo
search
Others

How to Export All Personal OneDrive URLs Using PowerShell

Ayan MasoodAyan Masood Oct 9, 2026 868 views

Question details

Microsoft 365 administrators need to retrieve and export a complete list of all users' personal OneDrive URLs for reporting, management, or migration purposes.

How to Export All Personal OneDrive URLs Using PowerShell
Product
Microsoft 365
Device & OS
Windows
Scenario
Administrative reporting and tenant migration data preparation.
Observed behavior
Admins require an automated, script-based way to pull all personal OneDrive site URLs instead of checking or compiling them manually.
Before you start

Ensure you have the SharePoint Online Management Shell installed on your computer and possess Microsoft 365 Global Administrator or SharePoint Administrator privileges.

Solution 1Recommended

Export OneDrive URLs via SharePoint Online Management Shell

Use official Microsoft PowerShell commands to query the tenant for personal sites and export the resulting URLs into a structured CSV file.

This method requires connecting to your SharePoint admin center via PowerShell. It will systematically query your organization's environment for all personal OneDrive sites and output them for further processing.

1
Open SharePoint Online Management Shell

Launch the SharePoint Online Management Shell as an administrator on your Windows machine.

2
Connect to your SharePoint Admin Center

Run the command Connect-SPOService -Url https://yourdomain-admin.sharepoint.com, replacing 'yourdomain' with your actual tenant name, and sign in with your administrator credentials.

3
Execute the Export Command

Run the documented Microsoft command to retrieve the URLs. For example: Get-SPOSite -IncludePersonalSite $true -Limit all -Filter "Url -like '-my.sharepoint.com/personal/'" | Select-Object Url | Export-Csv -Path "C:\OneDriveURLs.csv" -NoTypeInformation.

4
Review the CSV File

Navigate to the designated output folder on your computer and open the generated CSV file to verify that all user OneDrive URLs have been successfully exported.

Export OneDrive URLs via SharePoint Online Management Shell
Execution Time for Large Tenants: If your organization has a massive number of users, this script may take a significant amount of time to run. Ensure your PowerShell session remains active and uninterrupted.
Free Microsoft Office alternative

Manage and Analyze Your Exported Data with WPS Office

After exporting your OneDrive URLs to a CSV file, use WPS Office to quickly open, filter, and analyze the data. WPS Office is a lightweight, free alternative to Microsoft Office that offers full compatibility with Excel spreadsheet formats.

  1. 1. Download and Install: Get WPS Office for free from the official website and install it on your computer.
  2. 2. Open WPS Spreadsheets: Launch the application and select Spreadsheets to begin.
  3. 3. Import the Exported File: Open the CSV file you generated via PowerShell to easily format, filter, and organize the OneDrive URLs.
Fully compatible with Microsoft Excel (.csv, .xlsx) for seamless data analysis and reporting.Lightweight design ensures fast loading of large administrative datasets and lists.Familiar, tabbed user interface requires no learning curve for Microsoft Office users.Free to use for everyday office tasks, formatting, and administrative management.
microsoft office alternative - wps office

Frequently Asked Questions

Do I need a specific administrator role to run this PowerShell command?

Yes, you must be assigned either the Global Administrator or SharePoint Administrator role in your Microsoft 365 tenant to successfully retrieve personal OneDrive URLs.

Why is my PowerShell script returning an access denied error?

This typically occurs if you have not properly authenticated using the Connect-SPOService command with the correct admin center URL, or if your Microsoft 365 account lacks the necessary administrative permissions.

Can I filter the PowerShell export for specific users only?

Yes, you can modify the PowerShell script using the Where-Object cmdlet to filter the results based on specific user properties, such as department, licensing, or active status before exporting to CSV.

Does this script work on Mac or Linux operating systems?

The traditional SharePoint Online Management Shell is designed primarily for Windows. However, Mac and Linux users can utilize PowerShell Core with the cross-platform Microsoft 365 CLI or PnP PowerShell modules to achieve similar administrative tasks.