Sep 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?
Sep 01 2017 03:53 AM
Sep 01 2017 05:46 AM
SolutionYou can refer the this blog and it will be helpful for you
Sep 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.
Dec 12 2017 06:36 AM
Had the same thing pop up in our tenant. This script helped resolve it, Thanks!!!
Sep 21 2018 02:32 PM
Hello Jesper,
Do you recall the steps to roll back the administrator-owner assignment to the one drives?
Thanks,
Mario
Mar 07 2019 11:43 PM - edited Mar 07 2019 11:44 PM
Hi Jesper, what where the exact steps in ShareGate?
Apr 05 2019 09:10 AM
Apr 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
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"
Apr 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.
Apr 12 2019 01:20 AM - edited Apr 12 2019 01:21 AM
Apr 12 2019 01:20 AM - edited Apr 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
er admin@contoso.onmicrosoft.com
May 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,
here is the link : https://support-desktop.sharegate.com/hc/en-us/articles/115000647528?input_string=my+name+showing+up...
Feb 27 2020 01:46 PM
Mar 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.
Nov 15 2023 12:27 AM
Prerequisites:
Add Secondary Site Collection Admin for all OD4B Users:
Using the below Powershell script you can add the secondary site collection admin for all OD$B users.
In the script, replace the AdminURL and SecondaryAdmin with correct values.
Function Add-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 $True -ErrorAction SilentlyContinue Write-Host "Added secondary admin to the site $($OneDriveURL.URL)" } } Add-OnedriveSecondaryAdmin -SecondaryAdmin "email address removed for privacy reasons" -AdminURL "https://Tenantname-admin.sharepoint.com"
Remove Secondary Site Collection Admin for all OD4B Users:
To remove the secondary site collection admin, in the above script, just change the Set-SPOUser cmdlet’s parameter “IsSiteCollectionAdmin” value to $false.
Sep 01 2017 05:46 AM
SolutionYou can refer the this blog and it will be helpful for you