Share via


Enable Administrator to access all users' OneDrive for Business

Download, install and run the SharePoint Online Management Shell
https://www.microsoft.com/en-us/download/details.aspx?id=35588

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

  • Anonymous
    February 05, 2015
    This does not seem to work. Error message Connect-SPOService not recognized as a valid command
  • Anonymous
    November 02, 2015
    Make sure you run the SharePoint Online Management Shell as an administrator. In addition the SPOService URL should be https://-admin.sharepoint.com