How to clear the SharePoint Server configuration cache using PowerShell

If you have several servers in your SharePoint Server (on-premises) farm, repeating the manual steps for clearing the configuration cache on each can be time consuming. PowerShell really shines in situations like these to help us be more productive and efficient.

The following PowerShell script can be used to clear the SharePoint configuration cache on a server. I’ve recently tested this on SharePoint 2019 servers with success. Just be sure to run it on each server for which you’re clearing the cache, then remember to go back to each and press “ENTER” in each PowerShell window as the script instructs you so that it restarts the timer service after all servers have had their cache cleared.

This script follows the same steps you’d perform manually. It loads the SP snap-in if needed, stops the timer service, deletes the xml files in the Config directory, sets the cache.ini file’s value to 1 to reset the cache, then restarts the timer service (once you press Enter).

Clear SharePoint configuration cache using PowerShell

  1. Run PowerShell as administrator (right-click, run as administrator).
  2. Copy and paste the following script, making no changes to its contents. It will work as-is.
  3. Hit Enter to run the script (unless using ISE, then click “Run”).
  4. Repeat steps 1-3 for each SharePoint server on which you’re clearing the cache.
  5. When this has run on all SharePoint servers you wish, go back to each and hit Enter in PowerShell to restart the timer service on each.

Increasing MySite OneDrive for Business Storage

I recently ran into the following error message when using OneDrive for Business via MySites (on-prem 2016).

“No free space. Your site is out of storage space and changes can’t be saved…”

The recommendation is to empty your recycle bin, but the recycle bin is probably empty.

The default storage limit for MySites is set to 100 MB (which doesn’t go so far these days).

If you already have a bunch of personal sites created, it’s not as easy as tweaking the quota template. You will need to update the quota template for future sites, then reset all existing sites to use the updated template as well.

Update the Quota Template

Learn more on quota templates: Create, edit, and delete quota templates in SharePoint Server

Set existing sites to use updated template

Now that you’ve set the storage quota template for future sites, we need to update pre-existing sites to adopt this new storage limit. We’ll need to do this via PowerShell.

  1. Remote connect to a SharePoint server
  2. Open SharePoint 2013/2016 Management Shell as administrator (right-click, Run as Administrator)
  3. Run the following script, replacing the web app address with your own, and the template name if different from Personal Site
    $SPWebApp = Get-SPWebApplication https://mysites.MYORG.org
    
    foreach ($SPSite in $SPWebApp.Sites)
    {
        if ($SPSite -ne $null)
        {
            Set-SPSite -Identity $SPSite.url -QuotaTemplate "Personal Site"
            $SPSite.Dispose()
        }
    }

And that’s it! Once that has run successfully, all of your MySites should now have the new limit in place.