Is there a powersheel script to get a list of all OneDrive for business site/storage where a particular person is site collector admin?

Aman Akhauri 1 Reputation point

I want to get a list of all the OneDrive/sharepoint site location where is site collector admin.

SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
2,800 questions
OneDrive Management
OneDrive Management
OneDrive: A Microsoft file hosting and synchronization service.Management: The act or process of organizing, handling, directing or controlling something.
1,194 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,455 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Jinwei Li-MSFT 4,726 Reputation points Microsoft Vendor

    Hi @Anonymous ,

    Please follow the steps:

    1. Grant Admin Access to All OneDrive for Business Site Collections.
        #Set Runtime Parameters  
        #Global Admin  
        #Connect to SharePoint Online Admin Center  
        Connect-SPOService -Url $AdminSiteURL -credential (Get-Credential)  
         #Get all OneDrive for Business Site collections  
        $OneDriveSites = Get-SPOSite -Template "SPSPERS" -Limit ALL -IncludePersonalSite $True  
        Write-Host -f Yellow "Total Number of OneDrive Sites Found: "$OneDriveSites.count  
        #Add Site Collection Admin to each OneDrive  
        Foreach($Site in $OneDriveSites)  
            Write-Host -f Yellow "Adding Site Collection Admin to: "$Site.URL  
            Set-SPOUser -Site $Site.Url -LoginName $SiteCollAdmin -IsSiteCollectionAdmin $True  
        Write-Host "Site Collection Admin Added to All OneDrive Sites Successfully!" -f Green  
    2. Please run the below PowerShell script to get a particular person site collection.
       #Set Config Parameters  
       Try {  
           #Setup Credentials to connect  
           $Cred= Get-Credential  
           #Setup the context  
           $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($AdminSiteURL)  
           $Ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)  
           #Get the User  
           $User = $Ctx.web.EnsureUser($UserAccount)  
           #Get OneDrive Site URL from User Profile  
           $PeopleManager = New-Object Microsoft.SharePoint.Client.UserProfiles.PeopleManager($Ctx)  
           $UserProfile = $PeopleManager.GetPropertiesFor($User.LoginName)  
           #Get the User Profile Property  
           Write-host $UserProfile.PersonalUrl  
       Catch {  
           write-host -f Red "Error Getting User Profile Properties!" $_.Exception.Message  

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.