Last active
May 15, 2021 12:07
-
-
Save plamber/bac2456f1dca2bdfc51d52a02f2339fa to your computer and use it in GitHub Desktop.
Remove user from site collection and add a new site collection owner
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$userToAdd = "<upnOfUserToAdd>" | |
$userToRemove = "<upnOfUserToRemove>" | |
$webUrl = "<spoUrl>" | |
$m365Status = m365 status | |
Write-Host $m365Status | |
if ($m365Status -eq "Logged Out") { | |
# Connection to Microsoft 365 | |
m365 login | |
$m365Status = m365 status | |
} | |
m365 spo user remove --webUrl $webUrl --loginName "i:0#.f|membership|$userToRemove" --confirm | |
m365 spo site classic set --url $webUrl --owners $userToAdd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment