How to Gain Owner Access to OneDrive for Business Sites in Office 365?
By default, When SharePoint My Site or OneDrive site collection is created by the user, SharePoint assigns the primary site collection administrator or the OneDrive Owner rights to the user. In some cases, you may need to access another user’s OneDrive for Business site. E.g., The user left the company, and the manager of the user wants to gain access, Backup purposes, compliance, security, etc.
Access Any User’s OneDrive site as Global Administrator:
If you have “Global Administrator” rights, follow these steps to access OneDrive for any user in the tenant:
- Login to Microsoft Admin portal at https://admin.microsoft.com/,
- Expand Users >> Active Users >> Search and find the user to get OneDrive site access.
- Click on the user name to open the property pane >> Click on “OneDrive” tab and then Click on “Create link to files” link. This creates link to the OneDrive site of the user and adds you as site collection administrator to that site.
What if you have only “SharePoint Admin” rights but not a global administrator?
How to get admin access to the OneDrive for Business site in Office 365?
How to grant access to OneDrive for Business site to another user? To gain access to a user’s OneDrive site, follow these steps:
- Login to SharePoint Online Admin Center
- Click on the “More Features” and then the “User Profiles” link from left navigation
- Click on the “Manage User Profiles” link under the “People” group
- Search and pick the user profile to which you want to gain access. From the search result, click on the menu item “Manage site collection owners” from the context menu.
- By default, The owner of the OneDrive site collection is listed as the Primary Site Collection Administrator and in Site Collection Administrators. (You can have only one primary site collection Admin!). Add any additional administrators to the site collection in the “Site Collection Administrators” field. You can change the primary site collection administrator as well to remove the owner from OneDrive for Business site.
- Click on “OK” to commit your changes!
Now, you can gain access to all files and folders for the particular user. Instead of manually doing these steps to gain access to the OneDrive site, you can use the PowerShell script to add administrator permissions to OneDrive for business sites.
PowerShell to Add Site Collection Administrator to OneDrive for Business Site Collection:
If you need to access another user’s OneDrive for Business site, you’ll need to either change the site collection owner or add additional administrators to the site collection. Use this PowerShell script on SharePoint Online Management Shell to add an administrator to OneDrive for business.
#Set Runtime Parameters
$AdminSiteURL="https://crescent-admin.sharepoint.com"
$OneDriveSiteUrl="https://crescent-my.sharepoint.com/personal/biadmin_crescent_com"
$SiteCollAdmin="[email protected]"
#Get Credentials to connect to SharePoint Admin Center
$Cred = Get-Credential
#Connect to SharePoint Online Admin Center
Connect-SPOService -Url $AdminSiteURL -credential $Cred
#Add Site Collection Admin to the OneDrive
Set-SPOUser -Site $OneDriveSiteUrl -LoginName $SiteCollAdmin -IsSiteCollectionAdmin $True
Write-Host "Site Collection Admin Added Successfully!"
This PowerShell grants owner access to OneDrive for business to another user.
Grant Admin Access to All OneDrive for Business Site Collections
As there is no direct user interface to 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="[email protected]"
#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
This script adds site collection admin to all OneDrive for Business site collections. By adding a user as a site owner or site collection administrator, you are granting full access to all the files and folders on the site. How about adding a new admin to all existing sites where a particular user was a site owner?
#Parameters
$TenantAdminURL = "https://crescent-admin.sharepoint.com"
$OldAdminID = "[email protected]"
$NewAdminID = "[email protected]"
#Connect to SharePoint Admin Center
Connect-SPOService -url $TenantAdminURL
#Get All Sites where a particular user is owner
$Sites = Get-SPOSite -IncludePersonalSite $true -Limit All | Where {$_.Owner -eq $OldAdminID}
#Add NewAdmin as Site Collection Owner to all sites
$Sites | ForEach-Object {
Set-SPOUser -Site $_.Url -LoginName $NewAdminID -IsSiteCollectionAdmin $True
Write-host "Added Site collection Admin to" $_.URL
}
PnP PowerShell to Add Site Collection Admin to OneDrive Site
Here is how to add OneDrive for Business site collection administrator with PowerShell:
#Set Runtime Parameters
$AdminSiteURL="https://crescent-admin.sharepoint.com"
$OneDriveSiteUrl="https://crescent-my.sharepoint.com/personal/sjackson_crescent_com"
$SiteCollAdmin="[email protected]"
#Connect to PnP Online
Connect-PnPOnline -Url $AdminSiteURL -Interactive
#Change OneDrive Ownership
Set-PnPTenantSite -Url $OneDriveSiteUrl -Owners $SiteCollAdmin
Similarly, You can add a site collection administrator to all OneDrive for business sites as:
#Set Parameters
$AdminSiteURL="https://crescent-admin.sharepoint.com"
$SiteCollAdmin="[email protected]"
#Connect to PnP Online to the Tenant Admin Site
Connect-PnPOnline -Url $AdminSiteURL -Interactive
#Get All OneDrive Sites
$OneDriveSites = Get-PnPTenantSite -IncludeOneDriveSites -Filter "Url -like '-my.sharepoint.com/personal/'"
#Loop through each site
ForEach($Site in $OneDriveSites)
{
#Add Site collection Admin
Set-PnPTenantSite -Url $Site.URL -Owners $SiteCollAdmin
Write-Host -f Green "Added Site Collection Admin to: "$Site.URL
}
To remove OneDrive Site collection Admin, use: How to Remove Site Collection Administrator from OneDrive?
How can you modify this script to automate adding a user’s manager as secondary admin to only a list (.CSV file) of OneDrives
How do I add O365 Group as secondary admin? The O365 group shows as ” member” in sharepoint GUI…
There is no “Secondary Admin” in SharePoint Online! You can add Site collection Administrators to SharePoint Online site through PowerShell as in: How to Add Site Collection Administrator in SharePoint Online?