09-01-2017 03:27 AM
09-01-2017 03:27 AM
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 now he is owner on all OneDrive (the users are still owner too).
But I need to remove his account, and wanted to hear if any one knows a good script to do this?
09-01-2017 03:53 AM
09-01-2017 05:46 AMSolution
You can refer the this blog and it will be helpful for you
09-03-2017 11:25 PM
Thanks for your inputs. We were lucky that Sharegate had a setting to roll back this setting so the problem is solved.
12-12-2017 06:36 AM
Had the same thing pop up in our tenant. This script helped resolve it, Thanks!!!
09-21-2018 02:32 PM
Do you recall the steps to roll back the administrator-owner assignment to the one drives?
03-07-2019 11:43 PM - edited 03-07-2019 11:44 PM
Hi Jesper, what where the exact steps in ShareGate?
04-05-2019 09:10 AM
04-05-2019 11:21 PM
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
#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"
04-09-2019 07:00 AM
I do have Global Admin privileges. Please clarify something that may help me. I am under the impression that there are two "Secondary" settings that can be granted, Admin and Owner. The script is using the admin, but I am looking to remove an owner.
04-12-2019 01:20 AM - edited 04-12-2019 01:21 AM
By default you can sent only one owner per site collection (Onedrive) so you can change the owner using below script and it will remove your old owner.
Set-SPOSite -Identity https://contoso-my.sharepoint.com/personal/user_contoso_onmicrosoft_com -Own
05-13-2019 09:34 PM
@Jesper Stein I understand this is old thread, there is option in sharegate tool to remove name of the user from Site collection adminstrator from all one drive site,
03-30-2020 02:53 AM
@Jesper SteinIt seems you've solved this but there is a setting in ShareGate under Settings > Permissions & Notifications > Auto Assign as Administrator. It looks like a handy setting to turn off but it will add the user to all OneDrives within your tenancy.
After speaking to ShareGate support they sent me this link which provides a solution.