Wednesday, June 3, 2015

Stop Distributed cache host gracefully

## Settings you may want to change for your scenario ##
$startTime = Get-Date
$currentTime = $startTime
$elapsedTime = $currentTime - $startTime
$timeOut = 900

    Write-Host "Shutting down distributed cache host."
$hostInfo = Stop-CacheHost -Graceful -CachePort 22233 -ComputerName

while($elapsedTime.TotalSeconds -le $timeOut-and $hostInfo.Status -ne 'Down')
     Write-Host "Host Status : [$($hostInfo.Status)]"
     $currentTime = Get-Date
     $elapsedTime = $currentTime - $startTime
     $hostInfo = Get-CacheHost -HostName -CachePort 22233

Write-Host "Stopping distributed cache host was successful. Updating Service status in SharePoint."
Write-Host "To start service, please use Central Administration site."
catch [System.Exception]
Write-Host "Unable to stop cache host within 15 minutes."

Source:Microsoft Technet
It is always advised to stop DC service on SharePoint 2013 before a server is stopped/restarted as per one of the Premium case we worked with Microsoft.

No comments:

Post a Comment