Forum Discussion
Removing owner from all OneDrives....
- 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
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 https://support-desktop.sharegate.com/hc/en-us/articles/115000647528-Can-I-remove-myself-as-an-administrator-after-I-have-auto-assigned-myself-as-one- which provides a solution.
- Edwin_Tek530Nov 15, 2023Copper Contributor
Prerequisites:
- SharePoint Online PowerShell module
- This script users ‘Set-SPOUser’ cmdlet. You must have the SharePoint Online global administrator permission to run the cmdlet.
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.