How to Export All Personal OneDrive URLs Using PowerShell
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.

- 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.
Ensure you have the SharePoint Online Management Shell installed on your computer and possess Microsoft 365 Global Administrator or SharePoint Administrator privileges.
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.
Launch the SharePoint Online Management Shell as an administrator on your Windows machine.
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.
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.
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.

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. Download and Install: Get WPS Office for free from the official website and install it on your computer.
- 2. Open WPS Spreadsheets: Launch the application and select Spreadsheets to begin.
- 3. Import the Exported File: Open the CSV file you generated via PowerShell to easily format, filter, and organize the OneDrive URLs.

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.




