Introduction
I was working on a project to upgrade SP servers to the latest OS, and I encountered a problem removing servers from the farm. Also, the Distributed Cache Service was available on the server. Since I needed to modify the server architecture, I just stopped the service and ran the configuration wizard to remove the server from the farm which was causing the failure of psconfig.
This issue will occur if your distributed cache service is enabled on the server which is you are trying to remove. To perform this activity successfully we need to stop the distributed cache service and delete the targeted server.
- Open the SharePoint Management shell and run the below command with a few necessary changes.
- Retrieve the server name/hostname to be removed from the server.
- To stop the distributed service on the server, go to system settings>services on the server> select "Distributed Cache" and click on Stop
- Once it's stopped, verify that distrubutedcacheservices.exe service has disappeared from task manager under services, if not select the service and kill this manually.
- We can perform a server reboot also in the case that the task manager still shows the distributed service.
- $SPFarm = Get-SPFarm
- $cacheClusterName = "SPDistributedCacheCluster_" + $SPFarm.Id.ToString()
- $cacheClusterManager = [Microsoft.SharePoint.DistributedCaching.Utilities.SPDistributedCacheClusterInfoManager]::Local
- $cacheClusterInfo = $cacheClusterManager.GetSPDistributedCacheClusterInfo($cacheClusterName);
- $instanceName ="SPDistributedCacheService Name=AppFabricCachingService"
- $serviceInstance = Get-SPServiceInstance | ? {($_.Service.Tostring()) -eq $instanceName -and ($_.Server.Name) -eq "Server name for server you are trying to remove"}
- $serviceInstance.Delete()
- Change the 6th line to the server name which you are targetting instead; "Server name for server you are trying to remove".
- Execute the above script and then run psconfig, or remove the server from the farm and it will work as expected.