How Can I Automate Cleaning Useless SharePoint Sites?
Asked by
guitar+capo
Hi everyone! I'm currently interning and I've been tasked with the manual job of cleaning up unnecessary sites from SharePoint, which has proven to be quite repetitive and tedious. I suspect there must be a way to automate this cleaning process. The focus is on sites that are under 2GB in size.
Here's what I'm hoping to achieve:
1. Make myself an admin on all targeted sites so I can manage them freely.
2. Identify and delete sites created by obsolete users that are under 1GB and have not been modified (not just 'last visited') since 2024.
3. Remove all directories that have not seen any modifications since 2024, being careful not to delete directories that contain elements modified after that date. This is particularly sensitive as I don't want to lose any valuable data by mistake.
I have admin access at my company and an OnMicrosoft address. I've tried tackling the first goal but ran into issues, especially with errors regarding my ID, even though I have the permissions necessary for these tasks.
Is this goal realistic for my skill level? What's the best way to get started? What tools should I explore? I'm convinced that if something can be done manually through the GUI, there should be a more efficient way to do it via the command line interface. However, I'm still getting familiar with PowerShell and Microsoft's limitations. Thanks for any guidance!
Answers
Consider checking out the Graph API; it can make a lot of these tasks easier! It might seem daunting at first, but trust me, it's worth it. Once you get the hang of it, you'll find it simplifies many repetitive processes.
Reply to this answer
First off, make sure you have the correct PowerShell modules installed for SharePoint, as theyโre essential for this task. Be careful thoughโyou donโt want to run your scripts on live data until you're absolutely certain they work correctly. Try creating test files and changing their attributes to see how your scripts behave first. You should also think about the timing of these operations; moving large amounts of files may disrupt users, so plan accordingly!
strata_6m: Thanks for the detailed response! Iโm mostly dealing with sites under 2GB, so it sounds manageable. Iโll follow your advice on testing. Itโs super helpful!
Reply to this answer
Add your answer
Answers are reviewed before publication.
strata_6m: I was hesitant about the Graph API too, but I've heard it really streamlines things. Iโll definitely look into it!