How to Clear SharePoint Configuration Cache using PowerShell?

Clearing SharePoint configuration cache would be the solution for many common issues such as “An update conflict has occurred, and you must re-try this action”. Manually clearing the SharePoint 2007 configuration cache is explained in another article: How to Clear SharePoint Configuration cache? and this one is the PowerShell version of clearing SharePoint 2007/2010/2010 configuration cache.

Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue

#Stop SharePoint 2013 Timer service
Stop-Service SPTimerV4

#Configuration Cache folder
$folders = Get-ChildItem C:\ProgramData\Microsoft\SharePoint\Config 

#Get the GUID folder where cache.ini lives.
foreach ($folder in $folders)
    $items = Get-ChildItem $folder.FullName -Recurse
    foreach ($item in $items)
            if ($item.Name.ToLower() -eq "cache.ini")
                    $cachefolder = $folder.FullName
#Delete all XML Files
$cachefolderitems = Get-ChildItem $cachefolder -Recurse
    foreach ($cachefolderitem in $cachefolderitems)
            if ($cachefolderitem -like "*.xml")
#Set "Cache.ini" file's content to 1        
$a = Get-Content  $cachefolder\cache.ini
$a  = 1
Set-Content $a -Path $cachefolder\cache.ini

#Start SharePoint Timer Service
start-Service SPTimerV4 

Credits to:

Reset SharePoint 2013 Configuration Cache on all servers:

This one does it on all the servers in SharePoint farm:

Add-PSSnapin microsoft.sharepoint.powershell -ea SilentlyContinue

#Get all SharePoint Servers
$Servers = Get-SPServer | ? {$_.Role -ne "Invalid"} | Select -ExpandProperty Address

#Iterate through each server and reset SharePoint config cache
Invoke-Command -ComputerName $Servers -ScriptBlock {
try {
        Write-Host "$env:COMPUTERNAME - Stopping timer service"
        Stop-Service SPTimerV4

        #Get Config Cache Folder
        $ConfigDbId = [Guid](Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\15.0\Secure\ConfigDB' -Name Id).Id #Path to the '15 hive' ConfigDB in the registry
        $CacheFolder = Join-Path -Path ([Environment]::GetFolderPath("CommonApplicationData")) -ChildPath "Microsoft\SharePoint\Config\$ConfigDbId"

        Write-Host "$env:COMPUTERNAME - Clearing cache folder $CacheFolder"
        #Delete all XML Files
        Get-ChildItem "$CacheFolder\*" -Filter *.xml | Remove-Item

        Write-Host "$env:COMPUTERNAME - Resetting cache ini file"
        $CacheIni = Get-Item "$CacheFolder\Cache.ini"
        Set-Content -Path $CacheIni -Value "1"
        Write-Host "$env:COMPUTERNAME - Starting timer service"
        Start-Service SPTimerV4


Salaudeen Rajack

Salaudeen Rajack is a SharePoint Architect with Two decades of SharePoint Experience. He loves sharing his knowledge and experiences with the SharePoint community, through his real-world articles!

One thought on “How to Clear SharePoint Configuration Cache using PowerShell?

Leave a Reply