Tuesday, May 11, 2021

SharePoint Modern Page: Site Collections Directory

Adding a site collection directory to a SharePoint classic page was easy. However, with the new modern pages in SharePoint, it has become more challenging. A quick, easy way I have found to accomplish this need is to use the Highlighted Content web part and a custom query. See below for details.

1. Add the Highlighted Content web part on the page where you want the site collection directory.

2. Edit the Highlighted Content web part, select 'Custom query', select 'All sites' for the Source, and then add the following custom query in the 'Query text (KQL)' box: Path:"https://tenant.sharepoint.com/sites/*" contentclass:STS_Site. See screenshot below for an example. To sort the results on the page, you are given the option to use a managed property to sort on. As you can see in the screenshot below, I searched for the term "string", and ultimately selected the 'RefinableString00" managed property, which sorted my site collections by site name.



3. Republish the page.

Thursday, February 25, 2021

Restore a deleted site collection (SharePoint 2010 / 2013 / 2016 / 2019 On-Premises)

Did you know that you can now restore a deleted site collection? Microsoft has issued two PowerShell commands for this need. The only caveat is that they only work in an on-premises farm. I tested both commands recently, and I can tell you firsthand that they work!

Get-SPDeletedSite: Gets a list of deleted site collections.

https://docs.microsoft.com/en-us/powershell/module/sharepoint-server/get-spdeletedsite?view=sharepoint-ps

Restore-SPDeletedSite: Restores a deleted site collection.

https://docs.microsoft.com/en-us/powershell/module/sharepoint-server/restore-spdeletedsite?view=sharepoint-ps