One Drive Full Control on all users using an office 365 Service Account

Sajith Gopalakrishnan Hema 1,056 Reputation points
2021-08-03T05:49:51.98+00:00

In Office 365, under User Profile - My Site Settings, enabled My Site Secondary Admin account and assigned a service account so that using that account, we can update one drive settings of other users in the company.

Using the service account, we can access the following url. However, not able to get the full control.

https://tenantname-my.sharepoint.com/personal/userfirstname_lastname_domainname_com/_layouts/15/viewlsts.aspx?view=14

Also when we try to access the below URL, it says access denied.

https://tenantname-my.sharepoint.com/personal/userfirstname_lastname_domainname_com/_layouts/15/user.aspx

The purpose is to customize one driver permission using the service account for all users in the company. How to achieve this ?

Microsoft 365 and Office | SharePoint | For business | Windows
{count} votes

1 answer

Sort by: Most helpful
  1. Allen Xu_MSFT 13,866 Reputation points
    2021-08-04T06:34:16.957+00:00

    Hi @Sajith Gopalakrishnan Hema ,

    As per my research, the My Site Secondary Admin setting is applicable only for new My Sites. For existing My Sites, as there is no direct user interface to do add site collection administrator to OneDrive for Business sites, here is the PowerShell script you can utilize to add additional administrators in bulk.

    #Set Runtime Parameters  
    $AdminSiteURL="https://crescent-admin.sharepoint.com"  
    $SiteCollAdmin="******@crescent.com"  
       
    #Get Credentials to connect to the SharePoint Admin Center  
    $Cred = Get-Credential  
       
    #Connect to SharePoint Online Admin Center  
    Connect-SPOService -Url $AdminSiteURL –credential $Cred  
       
    #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      
    

    If an Answer is helpful, please click "Accept Answer" and upvote it.
    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.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.