How can I automate cleaning up unused SharePoint sites?

0
0
Asked By TechieGuru92 On

Hey everyone! I'm currently interning and tasked with the job of manually cleaning up unnecessary sites from SharePoint, which is pretty repetitive. I'm looking for ways to automate this process since my main goals include getting admin access to all relevant sites, consolidating sites created by obsolete users under 1GB and unmodified since 2024, and deleting directories that haven't been modified since 2024 (while ensuring directories containing updated elements aren't deleted). I'm an admin in my organization with an OnMicrosoft address and have faced some errors while trying to automate these tasks, despite having the necessary rights. I'm curious if this is a doable project for me, any suggestions on where to start, and what tools I should use? I think if it's possible through the GUI, there's got to be a way to do it via command line too, but I'm not very familiar with PowerShell. Any advice would be greatly appreciated!

3 Answers

Answered By CodeMasterX On

To tackle your project, you'll likely need a combination of PowerShell modules. Make sure to check out the PnP PowerShell module along with the Microsoft Graph module (but consider just using the submodules as necessary). Just a heads-up: if a site is part of a unified group, you'll need proper permissions to make ownership changes. Trust me, if you can manage it manually in the GUI, you can definitely automate it with PowerShell!

Answered By SharePointNinja On

Be careful with using scripts to make actual changes. It's advisable to start by using your script in a read-only mode to identify which sites to merge or delete. Making bulk changes without thorough checks can lead to unexpected issues, and you don't want to mess things up unintentionally. I've worked with SharePoint, and while deleting a site collection usually just removes it and its contents, there can be complexities especially when sites are linked to teams. Test everything first!

InternExplorer -

Thanks for the tip, that's really helpful!

WebDevPro -

Yeah, always best to start cautiously with automation!

Answered By AdminWizard On

Have you considered using a policy from the SharePoint admin center? It can do a lot of the heavy lifting for you, like emailing past and present owners to check if anyone needs admin rights. You can even run it in simulation mode first to see what changes it would suggest without making any real adjustments. This could streamline your cleaning efforts significantly!

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.