A family of Microsoft on-premises document management and storage systems.
Hi @john john ,
Perhaps you can use PowerShell to Bulk Remove SharePoint Online Users from a CSV File.
Here are steps:
Create a CSV file and fill it in according to your requirements, then Format as Table.
UserID needs to be prefixed: i:0#.f|membership|
Use this PowerShell script:
#Variables
$CSVPath ="C:\UsersToAdd.csv"
#Get data from CSV
$CSVData = Import-Csv $CSVPath
#Iterate through each row in CSV
ForEach($Row in $CSVData)
{
Try {
#Connect to SharePoint Online Site
Write-host "Connecting to Site: "$Row.SiteURL
Connect-PnPOnline -Url $Row.SiteURL -Interactive
#Remove user
Remove-PnPUser -Identity $Row.UserID -Force
Write-host -f Green "`tRemoveded User $($Row.UserAccount)"
}
Catch {
write-host -f Red "Error Removing User:" $_.Exception.Message
}
}
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


