Hi @Nigel Foot ,
According to my research and testing, unfortunately, there is currently no PowerShell scripts to remove users from Web Parts on different sites. As you said, you need to manually remove user from $peoplePart.PropertiesJson
.
Also, if you want to remove a user from all SharePoint Online sites, you can use the following script:
#Parameters
$TenantURL = "https://crescent.sharepoint.com"
$UserID="i:0#.f|membership|sharaz@crescent.com"
#Get Credentials to connect
$Credential = Get-Credential
#Frame Tenant Admin URL from Tenant URL
$TenantAdminURL = $TenantURL.Insert($TenantURL.IndexOf("."),"-admin")
#Connect to PnP Online
Connect-PnPOnline -Url $TenantAdminURL -Credentials $Credential
#Get All Site collections - Filter BOT and MySite Host
$Sites = Get-PnPTenantSite -Filter "Url -like '$TenantURL'"
#Iterate through all sites
$Sites | ForEach-Object {
Write-host "Searching in Site Collection:"$_.URL -f Yellow
#Connect to each site collection
Connect-PnPOnline -Url $_.URL -Credentials $Credential
If((Get-PnPUser | Where {$_.LoginName -eq $UserID}) -ne $NULL)
{
#Remove user from site collection
Remove-PnPUser -Identity $UserID -Confirm:$false
Write-host "`tRemoved the User from Site:"$_.URL -f Green
}
}
More information for reference: SharePoint Online: PowerShell to Remove User from All Sites
Hope it can help you. Thanks for your understanding.
Note: Microsoft is providing this information as a convenience to you. The sites are not controlled by Microsoft. Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. Please make sure that you completely understand the risk before retrieving any suggestions from the above link.
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.