Enable Administrator to access all users' OneDrive for Business

Download, install and run the SharePoint Online Management Shell

Replace <domain> with your domain name and <tenant> with your SharePoint Online tenant name.

$objCreds = Get-Credential

Connect-SPOService -Url https://<tenant>.sharepoint.com -credential $objCreds

$colUsers = Get-SPOUser -Site https://<tenant>-my.sharepoint.com/ | Where-Object {$_.LoginName -like '*<domain>.com*'}

$colUsers = $colUsers.LoginName | ForEach-Object { $_.TrimEnd("<domain>") } | ForEach-Object { $_.TrimEnd("@") }

$colUsers | ForEach-Object { Set-SPOUser -Site https://<tenant>-my.sharepoint.com/personal/"$_"_<domain>/ -LoginName company_administrator@<domain>.com -IsSiteCollectionAdmin $true }

Comments (2)
  1. Sven says:

    This does not seem to work. Error message Connect-SPOService not recognized as a valid command

  2. Eric says:

    Make sure you run the SharePoint Online Management Shell as an administrator. In addition the SPOService URL should be https://-admin.sharepoint.com

Comments are closed.

Skip to main content