Forum Discussion
Eric Adler
Apr 25, 2017Steel Contributor
Global Admin Showing up with Access to All Users OneDrive for Business
We are seeing one of the global admin accounts (mine) as having accesss to ever users OneDrive account. While in OneDrive it says it Shared "Only You" when you click on it you see that two accoun...
Steve Hollingshead
Copper Contributor
You can use this script I wrote to get a list of every OneDrive account and then remove the offending user:
Edit - not sure why it is throwing HTML tags into the code, remove those - you get the point.
###Script written by thestephenh@yahoo.com
###Change Tenant name below
Connect-SPOService -url "<a href="https://TENANT-admin.sharepoint.com/" target="_blank">https://TENANT-admin.sharepoint.com/</a>"
###Export a CSV with every URL of every onedrive site - Get-SPOSite -IncludePersonalSite $true -Limit all -Filter "Url -like '-my.sharepoint.com/personal/'" | select Url | export-csv -Path c:\test\sites.csv
#type the person you want to remove on the following line
$SecondaryAdmin ="REMOVETHISUSER@CONTOSO.COM"
$users = Import-Csv -Path "C:\test\sites.csv"
foreach ($user in $users){
$site= $user.'Url'
Set-SPOUser -Site $site -LoginName $SecondaryAdmin -IsSiteCollectionAdmin $false
write-host "OneDrive Access for $SecondaryAdmin removed for $site"
}
SteveW_UCCS
Feb 24, 2020Copper Contributor
Steve Hollingshead Thank you for this. I did something similar, $sites = get-sposite -limit All, but it did not remove the admin from all OneDrives. -Steve