Monday 3 February 2014

Delete Distribute cache using PowerShell

Need the Farm name:
$SPFarm = Get-SPFarm
Need the Cache Name:
$cacheClusterName = "SPDistributedCacheCluster_" + $SPFarm.Id.ToString()
Need to use local (only) server as ClusterManager:
$cacheClusterManager = [Microsoft.SharePoint.DistributedCaching.Utilities.SPDistributedCacheClusterInfoManager]::Local
Need the Cluster name:
$cacheClusterInfo = $cacheClusterManager.GetSPDistributedCacheClusterInfo($cacheClusterName)
Need the Instance name:
$instanceName ="SPDistributedCacheService Name=AppFabricCachingService"
Need the service instance for the missing <computername>
$serviceInstance = Get-SPServiceInstance | ? {($_.Service.Tostring()) -eq $instanceName -and ($_.Server.Name) -eq "<computername>"}
Need to delete the instance reference:
$serviceInstance.Delete()

No comments:

Post a Comment