**Remove Server from farm** Freitag, 10. Mai 2019 10:03 **Remove Server from farm** by [Stacy Simpkins](https://anothersharepointblog.com/author/shar3pointpapa) \| posted in: [Distributed Cache](https://anothersharepointblog.com/category/distributed-cache), [PowerShell](https://anothersharepointblog.com/category/powershell), [SharePoint Administration](https://anothersharepointblog.com/category/sharepoint-administration), [Update](https://anothersharepointblog.com/category/update) \| [0](https://anothersharepointblog.com/remove-server-from-farm#virtue_comments) The best methods to remove a server from the farm are to either use the psconfig wizard or run Disconnect-SPconfigurationDatabase If that has not happened and someone deleted the VM without first disconnecting the vm from the farm, please recall that there is the off chance that the vm, at one point, may have participated in the distributed cache cluster. And, if that is the case, then you need to run the following, taking into account that the following assumes there were two servers that had been erroneously removed, by having the VM deleted before being removed from SharePoint. You might only need one instantiation of the serviceInstance and then call the delete method. In my case I had two servers named **servername** and **server2name.** In that case run this code \$SPFarm = Get-SPFarm \$cacheClusterName = \"SPDistributedCacheCluster\_\" + \$SPFarm.Id.ToString() \$cacheClusterName SPDistributedCacheCluster_0952ce0a-1ab3-4251-a6fd-52f7878c6c4a \$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 \"servername\"} \$serviceInstance.Delete() \$serviceInstance = Get-SPServiceInstance \| ? {(\$\_.Service.Tostring()) -eq \$instanceName -and (\$\_.Server.Name) -eq \"server2name\"} \$serviceInstance.Delete() \$cacheClusterInfo.CacheHostsInfoCollection
1 2 3 4 5 6 7 8 9 10 11 12 |
$SPFarm = Get-SPFarm $cacheClusterName = "SPDistributedCacheCluster_" + $SPFarm.Id.ToString() $cacheClusterName SPDistributedCacheCluster_0952ce0a-1ab3-4251-a6fd-52f7878c6c4a $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 "servername"} $serviceInstance.Delete() $serviceInstance = Get-SPServiceInstance | ? {($_.Service.Tostring()) -eq $instanceName -and ($_.Server.Name) -eq "server2name"} $serviceInstance.Delete() $cacheClusterInfo.CacheHostsInfoCollection |
---|