I have a scenario in which I have to remove the users from SharePoint after they have left the company.
Say, I have 5 users who left the company. So I'll write a CSOM code to read the names from a file and delete their respective MySites.
Assuming, I have 100 site collections. How do I delete those 5 users from these site collections?
One way is going to each site collection using CSOM and checking if the user has been granted any sort of permissions for that site and remove it from there. But that seems to be a long process if the user has been granted permissions in no more than 10 site collections. If we take it on a big scale where we have 500+ site collections, the above mentioned solution becomes more time and memory consuming.
Is there any other way to do that?
PS. I am not going to remove the users from AD. Only have to delete their My site and remove them from site collections.