Forum Discussion
Jesper Stein
Sep 01, 2017Brass Contributor
Removing owner from all OneDrives....
I need some help to a powershell script, that can remove an owner on all users OneDrive. The user is added trough a 3rd party tool named ShareGate (I think by mistake) by the Sharepoint admin, so no...
- Sep 01, 2017
You can refer the this blog and it will be helpful for you
http://www.jijitechnologies.com/blogs/add-remove-secondary-site-collection-admin-to-all-onedrive-for-business-users
NCRescueTech
Apr 05, 2019Copper Contributor
I know this thread is old, but it is the closest I have seen to my problem.
I may be wrong, but I think this answer only applies to the "Secondary Admin" permission. I have the problem where an outside partner is listed as an "Owner" on all personal sites/files. His name is not listed in the admin center under the "Secondary Owner". I inherited this mess, so I can't say how he got there.
For giggles, I have tried to run the referenced script on a test site. No luck.
I may be wrong, but I think this answer only applies to the "Secondary Admin" permission. I have the problem where an outside partner is listed as an "Owner" on all personal sites/files. His name is not listed in the admin center under the "Secondary Owner". I inherited this mess, so I can't say how he got there.
For giggles, I have tried to run the referenced script on a test site. No luck.
Manidurai Mohanamariappan
Apr 06, 2019Iron Contributor
I have rechecked the script is working fine and you need global administrator privilege to run this script. Try the below script to remove the secondary admin privilege and before run the script change the SecondaryAdmin ,AdminURL values
Function Remove-OnedriveSecondaryAdmin($AdminURL,$SecondaryAdmin)
{
#connect Spo service.
Connect-SPOService -Url $AdminURL
#Get all Onedrive URL's.
$OneDriveURLs = Get-SPOSite -IncludePersonalSite $true -Limit All -Filter "Url -like '-my.sharepoint.com/personal/'"
foreach($OneDriveURL in $OneDriveURLs)
{
#Add Secondary administrator to Onedrive Site.
Set-SPOUser -Site $OneDriveURL.URL -LoginName $SecondaryAdmin -IsSiteCollectionAdmin $false -ErrorAction SilentlyContinue
Write-Host "Added secondary admin to the site $($OneDriveURL.URL)"
}
}
Remove-OnedriveSecondaryAdmin -SecondaryAdmin "Admin@contoso.onmicrosoft.com" -AdminURL "https://Contoso-admin.sharepoint.com"