Hot Posts

6/recent/ticker-posts

How to Export OneDrive URLs for All Users in Microsoft 365


To export OneDrive URLs for all users in a Microsoft 365 environment, you can use PowerShell with the Microsoft Graph API or SharePoint Online Management Shell. Here’s how you can do it:

1️⃣Using PowerShell and SharePoint Online Management Shell

This method retrieves all user OneDrive URLs in a CSV file.

Steps to Export OneDrive URLs for All Users:

🚀 Install & Connect to SharePoint Online

  • Open PowerShell as an administrator and run:
      Install-Module -Name Microsoft.Online.SharePoint.PowerShell -Force -  AllowClobber
      Import-Module Microsoft.Online.SharePoint.PowerShell
     Connect-SPOService -Url https://yourdomain-admin.sharepoint.com
  • Replace yourdomain with your actual Microsoft 365 tenant name.

🚀 Retrieve and Export OneDrive URLs

  • Run the following command to get all users' OneDrive URLs and export them to a CSV file:
       Get-SPOUser -Site https://yourdomain-my.sharepoint.com | 
       Select-Object DisplayName, LoginName, PersonalUrl | 
       Export-Csv -Path C:\OneDriveURLs.csv -NoTypeInformation
 
  • Replace yourdomain with your Microsoft 365 tenant name.
  • The file OneDriveURLs.csv will be saved in C:\

  • 2️⃣Using Microsoft Graph PowerShell

    For environments using Azure AD and Microsoft Graph, follow these steps:

    1️⃣ Install and Connect to Microsoft Graph

    Install-Module Microsoft.Graph -Force Import-Module Microsoft.Graph Connect-MgGraph -Scopes "User.Read.All"

    2️⃣ Export OneDrive URLs

    Get-MgUser -All | Select-Object DisplayName, UserPrincipalName,
    @{Name="OneDriveURL";Expression={"https://yourdomain-my.sharepoint.com/personal/" + $_.UserPrincipalName.Replace("@", "_")}} | Export-Csv -Path C:\OneDriveURLs.csv -NoTypeInformation.

    • Adjust yourdomain accordingly.

    This script helps IT admins easily retrieve and export OneDrive URLs for all users in a Microsoft 365 organization. You can use these URLs for auditing, migrations, or management tasks.


    Post a Comment

    0 Comments