Modify OneDrive Site Admins with PowerShell

In our previous post Office 365 – Access a Users OneDrive Folder we looked at giving an Admin access to a users OneDrive files. In this post we will focus on adding and removing Site Admins, on a users Personal SharePoint Site (OneDrive), using PowerShell.

First we will need to connect to SharePoint Online (see an earlier post on how to do this Connect to SharePoint Online using PowerShell

We will use the Get-SPOSite cmdlet first to see the existing Primary Site Admin on the users Personal SharePoint site:-

Waste of time hey? We can assume the Primary Site Owner will always be the OneDrive user 🙂

Another way of doing this is with the User Principal Name:-

We have to use a different command to find any Secondary Site Admins using the Get-SPOUser cmdlet:-

Let us look at adding a Secondary Site Admin to the user’s Personal SharePoint Folder where “LoginName” is the user you are adding:-

So let us see what our Secondary Site Admin list looks like now

Great, we have two Secondary Site Admins. If required, how do we delete one of them. We run the same script as Set-SPOUser above but replace “IsSiteCollectionAdmin $True” with “IsSiteCollectionAdmin $false”:-

and when we use the Get-SPOUser command again, the Secondary Site Admin has been removed

This is quite a handy way to give yourself temporary access to a users OneDrive folder by adding yourself as a Secondary Site Admin

Modify OneDrive Site Admins with PowerShell
5 (100%) 1 vote

Leave a comment

Your email address will not be published.

Time limit is exhausted. Please reload CAPTCHA.

 

This site uses Akismet to reduce spam. Learn how your comment data is processed.

One thought on “Modify OneDrive Site Admins with PowerShell”