Add Or Remove The User From SharePoint Online Using PowerShell

This blog will help you to add or remove the users to the SharePoint online using PowerShell. Recently, I faced one strange issue - one of my SharePoint site owners was reporting, "I have granted an access to one of my colleagues but he is not able to access the SharePoint Site and he has been getting the “Access Denied” page."

At the moment, I had a try to add that person user principle name directly to the SharePoint using GUI interface and it was added successfully but when I tried to check his permission it kept on showing “none

Then again, I removed that person name and tried to add it again but no “GO”

Then, I added that username as a site collection administrator. Fortunately, that user can access the SharePoint site.

Ok, then I have decided to remove the user details from SharePoint using PowerShell and add it again. Then the issue has been resolved

Here are the PowerShell commands to add or remove the user from SharePoint Online.

#Connect the SharePoint Online
Connect-SPOService -URL https://tenant-admin.sharepoint.com

#Get the Site Collection URL
$siteURL = Read-host “Enter the Site Collection URL”

#Remove User from the SharePoint
Remove-SPOUser -Site $siteURL -LoginName [email protected]

#add user to the sharepoint
Add-SPOUser -Site $siteURL -LoginName [email protected] -Group Team site Members