Important Powershell commands for configuring Office webs apps in SharePoint 2013

Office-Web-Apps-Server-2013---die-neue-Architektur

 

1.New-OfficeWebAppsFarm –> This command is used to create a new Office Web Apps Server farm on the local computer.

The New-OfficeWebAppsFarm cmdlet creates a new Office Web Apps Server farm on the local computer. You have to run this cmdlet on the first server in the Office Web Apps Server farm and then add more servers to the farm by using the New-OfficeWebAppsMachine cmdlet.

Syntax:

New-OfficeWebAppsFarm -InternalUrl “https://server.corp.contoso.com” -ExternalUrl “https://server.external.contoso.com” -EditingEnabled:$true -SSLOffloaded

This example creates an Office Web Apps Server farm on the local server that has editing enabled for Office Web Apps. The farm is configured for load balancing by enablingSSLOffloaded, which automatically enables AllowHttp. If you are not using a load balancer, make sure that you set Certificate Name.

Syntax using the certificate name:

New-OfficeWebAppsFarm -InternalUrl “https://server.corp.contoso.com” –CertificateName “Web OWA” -EditingEnabled

2. New-OfficeWebAppsMachine –> The New-OfficeWebAppsMachine cmdlet adds the current server to an existing Office Web Apps Server farm and optionally sets one or more roles on the new server.

Syntax:

New-OfficeWebAppsMachine -MachineToJoin server1.contoso.com

The “MachineToJoin” switch takes care of adding the new machine to the Office Web apps farm

3. Remove-OfficeWebAppsMachine –>   This command removes the current server from the Office Web Apps Server farm. As part of this process, the cmdlet removes the web applications and shuts down the services that are related to Office Web Apps Server. This command can be used during scenarios where you’re planning to patch the  current Office web apps server. Do remember that you’re supposed to remove the OWA server which you’re planning to patch from the OWA farm and once you’re done patching you have to add it back.

Note: This is applicable only when you have OWA running as a farm with many servers on it .

4. New-SPWOPIBinding –> This command associates file name extensions or applications to actions on the current SharePoint farm where this cmdlet is run. Each binding allows you to use the WOPI application to view or edit files in your SharePoint library. For example, when a user sees a Word document in a SharePoint document list, the SharePoint list will display the available options to view or edit the document based on the actions that are bound to Word on that SharePoint farm.

Syntax:

New-SPWOPIBinding -ServerName “Server.corp.Contoso.com” :  This example creates bindings for all the applications and file name extensions that the WOPI application supports on the current SharePoint farm where this cmdlet is run.

New-SPWOPIBinding -ServerName “Server.corp.Contoso.com” -Application “Excel” :  This command associates Excel with all the actions that the WOPI application supports for Excel on the current SharePoint farm where this cmdlet is run.

5. Remove-SPWOPIBinding –> This command is used to remove all the bindings for applications, file name extensions, and their associated actions on the current SharePoint farm where this cmdlet is run

Syntax:

Remove-SPWOPIBinding -All:$true –> This example removes all bindings on the current SharePoint farm where this cmdlet is run.

Remove-SPWOPIBinding -Application “Excel” –> for excel alone.

Get-SPWOPIBinding -Action “MobileView” | Remove-SPWOPIBinding –> This example removes all bindings for Office Mobile Web Apps on the current SharePoint farm where this cmdlet is run.

6. Get-SPWOPIBinding –> This command returns a list of bindings that were created by using New-SPWOPIBinding on the current SharePoint farm where this cmdlet is run

Syntax:

Get-SPWOPIBinding -Server “Server.corp.Contoso.com” :  This example returns a list of bindings that were created on the current SharePoint farm where this cmdlet is run for the WOPI application “Server.corp.Contoso.com.”  The WOPI application may be the server that runs Office Web Apps Server.

Get-SPWOPIZone | Get-SPWOPIBinding :  This example returns a list of bindings that were created on the current SharePoint farm where this cmdlet is run for the zone configured for the WOPI application.

7. Set-SPWOPIBinding — > This command Updates the default click action for an application or file name extension binding.  The Set-SPWOPIBinding cmdlet updates the default click action for an application or file name extension binding. For example, you can set the default click action for viewing a Word document in a SharePoint library. To do this, you set the default action to true for the “view”-“Word” bindings

Syntax:

Get-SPWOPIBinding -Action “view” -Application “Word”| Set-SPWOPIBinding -DefaultAction –> This example sets the default click action to view for a Word document in a SharePoint library. You can verify that the default click action is set to view for Word by running the cmdlet Get-SPWOPIBinding –Action “view” –Application “Word”. The IsDefaultAction value is set to “True.”

8. New-SPWOPISuppressionSetting –> This command turns off Office Web Apps for the action, file name extension, or programmatic identifier that you’ve specified on the current SharePoint farm.

Syntax:

New-SPWOPISuppressionSetting -Extension “XLSX” -Action “view” &

New-SPWOPISuppressionSetting -Extension “XLS” -Action “view”

This example turns off the ability of a user to use Office Web Apps to view Excel workbooks that have file name extensions “.xlsx” or “.xls”.

 

 

Request Management in SharePoint 2013

Request Manager in SharePoint Server 2013 can route and throttle incoming requests to help improve performance and availability. Request Manager is functionality in SharePoint Server 2013 that enables administrators to manage incoming requests and determine how SharePoint Server 2013 routes these requests.

Overview:

Request Manager uses configured rules to perform the following tasks when it encounters requests:

 

  • Deny potentially harmful requests from entering a SharePoint farm.
  • Route good requests to an available server.
  • Manually optimize performance.

 

Request Management feature in SharePoint 2013 manages incoming requests by evaluating logic rules against the user requests in order to determine what/which action to take, and which machine or machines (Targets) in the farm should handle the requests. SharePoint Foundation Web Application Service of SharePoint 2013 handles and responds to all incoming requests through IIS. Load Balancer is used to distribute incoming traffic across all the web front end servers. It is not necessary that all the web front end servers should be serving the incoming requests. Good example for such scenario would be dedicated Crawl Web Front end server. In such cases, Load balancing features will be leveraged to ensure right requests are redirected to the right machines.

During Medium and Large scale hosting, the need for powerful request management becomes very important. Request Management feature of SharePoint 2013 fulfills this need through advanced routing and Throttling.

Architecture:

Request Management is used as a Service instance although there is no associated Service application. All configurations are performed using Windows PowerShell commands. Request Management is scoped and configured on per web application basis. Request Manager’s task is to decide two things: a SharePoint farm will accept a request, and if the answer is “yes”, to which front-end web server SharePoint Server will send it.

There are three logical components of the request manager:

  1. Throttling (Limit request) and Routing (route request)
  2. Prioritization (identify the group of servers to handle request)
  3. Load balancing (Identify the server to handle request).

When a new request is received, Request Manager is the first code that runs in a SharePoint farm. Although Request Manager is installed during setup of SharePoint Server on a front-end web server, the Request Management service is not enabled. You can use the Start-SPServiceInstance and Stop-SPServiceInstance cmdlets to start and stop the Request Management service instance respectively or the Manage services on server page on the SharePoint Central Administration website. You can use theRoutingEnabled or ThrottlingEnabled parametersofthe Set-SPRequestManagementSettings Windows PowerShell cmdlet to change properties of Request Manager.

Request Manager has two supported deployment modes:

  1. Dedicated
  2. Integrated.

 

  1. Dedicated Mode :

Dedicated mode

 

A set of front-end web servers is dedicated to managing requests exclusively. The front-end web servers that are dedicated to Request Manager are in their own farm (i.e. not a part of the SharePoint farm) that is located between the hardware load balancers (HLBs) and the SharePoint farm. The HLBs send all requests to the Request Manager front-end web servers. Request Manager that runs on these front-end web servers decides to which SharePoint front-end web servers it will send the requests and then routes the requests. Depending on the routing and throttling rules, Request Manager might ignore some requests without sending them to another server. The SharePoint front-end web servers do their normal tasks in processing requests and then send responses back through the front-end web servers that run Request Manager and to the clients.

Note that all farms are set up as SharePoint farms. All front-end web servers in Figure 1 are SharePoint front-end web servers, each of which can do the same work as any other. The difference between the farms is that the Request Manager front-end web servers have Request Manager enabled.

 

Dedicated mode is good for larger-scale deployments when physical computers are readily available. The ability to create a separate farm for Request manager provides two benefits: Request Manager and SharePoint processes do not compete for resources and you can scale out one without having to also scale out the other. This allows you to have more control over the performance of each role.

 

  • Request Manager and SharePoint processes do not compete for resources.
  • You can scale out each farm separately, which provides more control over the performance of each farm.

 

  1. Integrated Mode:

Integrated mode

In an integrated mode deployment, all SharePoint front-end web servers run Request Manager. Hardware load balancers send requests to all front-end web servers. When a front-end web server receives a request, Request Manager decides how to handle it.

  • Allow it to be processed locally.
  • Route it to a different front-end web server.
  • Deny the request.

Integrated mode is good for small-scale deployments when many physical computers are not readily available. This mode lets Request Manager and the rest of SharePoint Server to run on all computers. This mode is common for on-premises deployments.

 

SharePoint 2013 :Finding the search index location

Use the below PowerShell commands to find the search index location:

$ssa = Get-SPServiceApplication –Name “Search Service Application” $active = Get-SPEnterpriseSearchTopology -SearchApplication $ssa -Active Get-SPEnterpriseSearchComponent -SearchTopology $active

Below are the screenshots:

Index location 1

You will get the search index location as shown below :

Index location 2

November 10, 2015, cumulative update for SharePoint Server 2013 (KB3101373) is out :

Microsoft has released the November 2015 Cumulative Update for the SharePoint 2013 product family.

The  November 2015 CU we have full server packages (also known as Uber packages). No other CU is required to fully patch SharePoint.

November 2015 CU includes all fixes from November 2015 PU.

Note : All Updates for SharePoint 2013 require SharePoint Server 2013 SP1 to be installed first.

Download link for Nov 2015 CU :

https://support.microsoft.com/en-us/kb/3101373

If your farm has been on a patch level lower than July 2015 CU: Unlike other CUs – after installing the November 2015 CU you need to run the SharePoint 2013 Products Configuration Wizard on each machine in the farm. If you don’t run PSCONFIG after installing November 2015 CU (on a farm which had a lower patch level than July 2015 CU) crawl might no longer work – so ensure to schedule a maintenance window when installing this CU which includes PSCONFIG runs.Check this blog for more info on this :

https://blogs.technet.microsoft.com/stefan_gossner/2015/07/15/important-psconfig-is-mandatory-for-july-2015-cu-for-sharepoint-2013/

Issues addressed in this CU : 

  • Assume that you create host-named site collections and map an Intranet zone URL to the site collections. Then, you access an enterprise search center by using the Intranet zone URL. When you do a search in the search center and try to follow an item from the search results from the hover card dialog box, this operation fails with an internal error message.
  • After you apply view filters to a multivalued lookup column and a single-value lookup column, you may receive the following error message:
    • Exception from HRESULT: 0x80131904<br/><br/>Correlation ID:ID<br/>
  • After an anonymous user adds a new comment to a post, you can’t view comments for the post, and you receive the following error message:
    • TypeError: Unable to get property ‘trim’ of undefined or null reference.
  • When you use a third-party web browser to browse a calendar in SharePoint Server 2013, the Add button on a view of the calendar isn’t clickable.
  • Assume that you enter multiple lines of text in the About me field of a user profile in a SharePoint Server 2013 site. When you try to search the user by using some of the text, no result is returned. This issue occurs because the multiple lines of text is combined to one term.

Cleaning up disk space in SharePoint servers:

This article mainly discusses on the steps to be performed if you happen to come across a scenario where the “C drive”  is filled in the SharePoint server. In our environment we have the SharePoint Servers installed on the C drive and it’s very important that we maintain an adequate amount of free space in the C drive for SharePoint to function seamlessly.

Please use the WinDirStat tool to check the contents in the C drive .This will give you a detailed information about all the folders in the C drive and thus can be used to identify the folders which is larger in space.

WinDirStat Tool:

       WinDirStat is a disk usage statistics viewer and cleanup tool for various versions.

On start up, it reads the whole directory tree once and then presents it in three useful views:

  1. The directory list, which resembles the tree view of the Windows Explorer but is sorted by file/subtree size,

  2. The tree map, which shows the whole contents of the directory tree straight away,

  3. The extension list, which serves as a legend and shows statistics about the file types.

WinDirStat Tool download link :_ http://filehippo.com/download_windirstat/

Listed below are few scenarios that can contribute to the C disk space increase:

  1. The Windows update option is set as “ Download updates but let me choose whether to install them”

1

  If you choose this option in the “Windows update center” then the Windows update service will start to automatically download the updates from the Microsoft Update server and will be waiting for us to install it. The update files in this case will be automatically downloaded to the Software distribution folder(C:\Windows\SoftwareDistribution\Download) increasing the C drive space.

Fix:  Please make sure that this option is set to “Check for updates but let me choose whether to install them “. In this case the download center won’t download any updates from the Microsoft servers unless and until we manually click on the “download “button to download the updates. Hence this won’t result in unnecessary disk space increase.

2. Check whether “Diagnostic Logging” is set to “Verbose” in Central Administration. If that’s the case then the log file size will increase rapidly resulting in a disk space increase.

Note:  However, this depends on the path configured for “Diagnostic Logging “.If its set to some other drive other than the “C drive “ then there shouldn’t be any problem.

https://technet.microsoft.com/en-us/library/ee748619(v=office.14).aspx

23. Check the space consumed by the logged in user profiles. This can be done by navigating to System properties à User profiles. Check whether the space consumed by all the user profiles is normal .If you see any abnormal increase in the space consumed by any user profile then please go ahead and delete that profile by selecting that user profile and clicking on the “delete” button.

Note: If you delete the user profile from “System properties” then this will remove the user profile from the registry as well. The next time someone logs into the server with that account, a new user profile will be created for that account.

4

Missing Org Chart in SharePoint 2013 My site.

The Web Part, “Org Chart”, that was visible under the About Me section of MySites in previous versions of SharePoint is now hidden in SharePoint 2013 by default. But when you view the About Me page of any another employee it is displayed.  This behavior is by design and it’s for better performance reasons. 

In previous versions of SharePoint, the profile page always loaded the Org Chart web part.  Loading peer, manager and direct report data actually requires an extra database lookup which contributes to a longer page load time.  Since most users would prefer to have their personal profile page load faster than to see their own position in the organizational hierarchy, the Org Chart web part is hidden when a user views their own profile page.

SP2013OrganizationalChart_1

Steps for troubleshooting “My Tasks error in SharePoint 2013 My site“

This post is intended for those who are seeing an error as shown in the image below while accessing the “My Tasks” link in your SharePoint My site. As you all know for yourself the “My Task” link which you see in your SharePoint My site is driven by the “Work Management Service application” and it’s necessary to ensure that the WMA service is turned on and configured to run successfully. While I say the WMA service is the one that takes care of the “My Task “list that’s not the only component on which the “My Task “  list relies upon . There are couple of other dependencies such as “Search crawl” and “User Profile service” which takes care of the “My Task “list.

The “My Task” list in your SharePoint My site can display three different type of tasks ….

  1. The tasks assigned to you from Outlook ( this is possible only when you’re running Exchange Server 2013 and SharePoint Server 2013…they both need to be running on 2013 version )
  2. The tasks assigned to you from MS Project if you have that running in your environment and have configured that to sync with SharePoint.
  3. The tasks assigned to you using the default SharePoint “Task list “.

The Work Management Service Application provides functionality to aggregate tasks to a central location on SharePoint Server:

  1. Users get the possibility to view and track their to-dos and tasks.
  2. Tasks can be cached to a user’s personal site.
  3. Tasks can sync to Outlook where users can edit them wherever they have access to Outlook.
  4. Tasks can be aggregated from Exchange, Project Server and SharePoint.
  5. Based on ‘Provider model’ so that other systems can be integrated in the future.

Now, if the WMA (Work Management Service Application ) is not configured properly then you might end up seeing an error as shown in the figure below and you need to perform the below mentioned troubleshooting steps to get this fixed.

My task

Troubleshooting steps to fix this error:

  1. The Work Management Service Application should use the same account as the web application.
  2. Verify whether the service account for Work Management Service application has full control permissions on the User Profile Service application on Central Administration.
  3. Verify whether the service account for Work Management Service application has full control permissions on the Work Management Service application on Central Administration.
  4. Ensure that you do the above mentioned steps on the instance of the service application which is connected to the My site web application.
  5. Grant “Full Control” to the work management service account on the User Profile service application using “administrators” button on the ribbon.
  6. In addition to that grant “Full control” to the work management service account on the user profile service application using the “permissions” button on the ribbon.
  7. Ensure that the work management service account is given appropriate permissions in the “My site” content database.
  8. Check whether the service account of the Work management service application is equal to the identity of the web application pool because this could be an issue with the permissions too.
  9. Restart the Work management service and the user profile service on the servers.
  10. Perform an IIS reset.
  11. If this didn’t help ,please run the below mentioned PowerShell command

Run the PowerShell command to grant content access to a process account to the MY SITE web application:

  • $webApp = Get-SpWebApplication [URL of the MYSite web application
    $webapp.GrantAccessToProcessIdentity(“[Work Management account]”)
  • Note: this should do three things:
  •      Add the work management account to the user policy of the web application
  •      Add the work  management account to the config database with the permissions of     WSS_Content_Application_Pools
  •      Add the work management account to the My Site content database with the permissions of SPDataAccess.

12. Perform an IIS reset once done and also restarting the server and critical services is recommended.

IMPORTANT:

The tasks are stored in a hidden list called “WmaAggregatorList_User” at the personal site of individual users.

WMA aggregates tasks from SharePoint lists created in SharePoint Server (internally called TasksWithTimelineAndHierarchy-171) plus upgraded SharePoint lists from earlier versions of SharePoint (internally called Task-107 or GanttTasks-150).

 

Patching Distributed Cache in SharePoint Server 2013

The Distributed Cache plays an important role in SharePoint Server 2013 as it’s a key component for performance and caching. Distributed Cache is not a SharePoint service, it’s a standalone service called AppFabric 1.1 for Windows Server. SharePoint Server 2013 requires Windows Server App Fabric and the App Fabric 1.1 CU 1 (KB 2671763) to be installed .It takes care and improves the performance of the following features in SharePoint Server 2013:

  • Authentication
  • Newsfeeds
  • OneNote client access
  • Security Trimming
  • Page load performance

This document explains in detail about the procedure to be followed for patching the App Fabric component in Windows Server. An App Fabric Cumulative Update is exactly the same as a CU for SharePoint, it contains all previous CUs. So if we install CU6 you also get CU1 to CU5 installed.

List of App Fabric 1.1 Cumulative Updates:

Note: If you want to identify the version of App Fabric installed in your machine and also the CU version which is installed, please go to the “Programs and Features” section in Control panel and take a look at installed updates.

AF

  1. The version number would be listed there.
  2. The installed CU would also be listed there with the corresponding KB number.

 

System Requirements:

  1. Windows Server 2012/2012 R2 32-bit or 64-bit.
  2. Before applying the cumulative update, make sure you have administrative privileges on the computer where you’re installing this software.
  3. To apply this cumulative update package, we must have AppFabric 1.1 for Windows Server installed. Additionally, we should also have the Microsoft .NET Framework 4.5 installed.
  4. A system restart is required after installing the Cumulative Update.

Now let’s take a look on the steps to be followed for installing the CU on a server running SharePoint 2013.

Listed below are the steps to be followed for applying the App Fabric CU’s:

  1. Please download the CU from Microsoft download center .I’m considering the CU 6 here. Download link for App Fabric 1.1. CU 6 :_ https://support.microsoft.com/en-us/kb/3042099
  2. Once done downloading the cumulative update package to the server in which you’re going to run it, please run the below mentioned to gracefully shutdown the service instance on the local machine.

Stop-SPDistributedCacheServiceInstance –Graceful

  1. This command will gracefully shutdown the service instance on the local machine. A graceful shutdown means that all the cache items will be distributed to the other service instances in the cache cluster.
  2. Wait for minutes to make sure that all the cached items has properly propagated to the other servers.
  3. Now it’s time to run the package, run the patch executable and follow the instructions. It’s basically a next, next, finish procedure. The App Fabric 1.1 CU 6 doesn’t need any specific change to be made on the exe.config  file like how CU 3 did. So please proceed further by clicking next.
  4. Once you’re done installing the CU, please restart the computer.
  5. When the machine is back online, please run the below mentioned command to start the service instance again. The App Fabric Windows Service will be disabled when its shutdown and we are not supposed to start it manually. Please use the below mentioned PowerShell command to do that.

$instanceName =”SPDistributedCacheService Name=AppFabricCachingService”

$serviceInstance = Get-SPServiceInstance | ? {($_.service.tostring()) -eq $instanceName -and ($_.server.name) -eq $env:computername}

$serviceInstance.Provision()

  1. This command will turn on the Distributed Cache service instance on the machine and will start the AppFabric Windows Service.
  2. Once you’re done completing all the above mentioned steps you’re now ready to move on to the next machine.
  3. Please allow some time for the newly patched cache service instance to catch up.
  4. Finally run the below mentioned commands to check if the Distributed cache service is back online.

To see what  Distributed cache-servers SharePoint thinks there are run this:

Get-SPServiceInstance | ? {($_.service.tostring()) -eq “SPDistributedCacheService              Name=AppFabricCachingService”} | select Server, Status

For AppFabric run this from a machine already in the cache-cluster:

Use-CacheCluster

Get-CacheHost

  1. This will confirm whether the Distributed cache service is back online from a SharePoint as well as from an App Fabric perspective.
  2. For any reason, if you don’t see the status of the servers as “online”, please go ahead and run the below mentioned command to remove and re-add the Distributed Cache Service Instance.

To remove:  Remove-SPDistributedCacheServiceInstance

To Add   :    Add-SPDistributedCacheServiceInstance

  1. Run the remove command first and then wait for couple of minutes and then run the add command.
  2. At last, once everything looks fine you’re good to go ahead and patch the second server following the same steps mentioned above.

Troubleshooting Distributed Cache in SharePoint Server 2013

The Distributed Cache plays an important role in SharePoint Server 2013 as it’s a key component for performance and caching. Distributed Cache is not a SharePoint service, it’s a standalone service called AppFabric 1.1 for Windows Server. SharePoint Server 2013 requires Windows Server App Fabric and the App Fabric 1.1 CU 1 (KB 2671763) to be installed .It takes care and improves the performance of the following features in SharePoint Server 2013:

  • Authentication
  • Newsfeeds
  • OneNote client access
  • Security Trimming
  • Page load performance

It’s always quite comfortable to manage Distributed Cache in SharePoint Server 2013 using PowerShell and the same applies while troubleshooting it also .This articles discusses on the useful PowerShell commands that can be used to troubleshoot Distributed Cache service in SharePoint Server 2013.

                     Command                    Explanation
                  Use-CacheCluster This is used to enable cache administration via PowerShell.
                  Get-CacheHost This would get you the list of every server in the cluster as well as the state of the service on that server.
      Get-CacheHostConfig <HostName> <Port> This would give you the general configuration details about a specific host in the cache cluster. All Windows Server AppFabric cache hosts use TCP/IP to communicate with each other and support the cache cluster. The SharePoint distributed cache is an AppFabric cache behind the scenes and  it uses the default AppFabric ports for server to server communication. These ports should be allowed through your firewalls for the cacheservice  to function correctly.
           Get-CacheAllowedClientAccounts This would tell which accounts/groups have rights to connect to the cache cluster as clients. This seems to be the standard configuration in SharePoint 2013.
                   Get-Cache Gets a listing of all the default caches in the farm. All caches have the Id (Guid) of the farm appended to the name.
       Get-CacheConfig <CacheName> Gives you the details about a specific cache instance
         Restart-CacheCluster This will restart the distributed cache service on all servers in the cluster and it will also clear the contents of the cache.
  Stop-SPDistributedCacheServiceInstance -Graceful This will stop the distributed cache service on an individual machine. The Graceful parameter will allow the cache service to migrate cached items to another host in the cluster.
 Remove-SPDistributedCacheServiceInstance Removes a cache host from the cluster. The best practice is to stop the cache service before you remove it.
  Add-SPDistributedCacheServiceInstance This command will add the cache host back to the cluster. If there is more than one host in the cluster, it will take a few minutes for the service to start and for any cached items to be synchronized to the new host.
   Get-CacheClusterHealth  Returns health statistics for all of the named caches in the cache cluster.
    Clear-CacheLogging  This command is used to disable all logging for the current admin
    Get-CacheStatistics Gives the statistics for a Cache or for a Cache Host.
     Start-CacheHost This would start the Caching Service on the specified cache host. If no cache hosts are up in the cache cluster, use the Start-CacheCluster command instead
     Stop-CacheCluster Stops the Caching Services on all cache hosts in the cluster.
    Stop-CacheHost Stops the specified cache host service.
   Test-CacheConfigAvailability Tests the connection with the cache cluster configuration store. This command will throw an exception if the connection fails.

In addition to the commands listed above there are couple of other things which you’re supposed to know while troubleshooting Distributed Cache Service/App Fabric.

  1. Query AppFabric for Caching Servers/Statuses :

To get the list of servers that AppFabric thinks there should in the cluster run “Get-CacheHost” (use “Use-CacheCluster” if necessary). This command gives us the list of the servers and also their availability status as far as AppFabric’s concerned.

  1. Query SharePoint for Caching Servers/Statuses :

To do the same for SharePoint, run:

Get-SPServiceInstance | ? {($_.service.tostring()) -eq “SPDistributedCacheService Name=AppFabricCachingService”} | select Server, Status

This will give you the same kind of data but from SharePoint perspective.  Make sure all the servers show the status as “Online” but more importantly that both SP & AF have the same names between them. If you see “cacheHostInfo is null” somewhere then it’s quite likely there’s a mismatch here.

What if one or more App Fabric Service Instance is disabled?

Run the below mentioned PowerShell command …..

Get-SPServiceInstance | ? {($_.service.tostring()) -eq “SPDistributedCacheService Name=AppFabricCachingService”} | select Server, Status

If any status shows as “disabled” then we have a problem and in that case please perform the below mentioned steps:

  1. Remove the service-instance (see above).
  2. Try re-adding it with Add-SPDistributedCacheServiceInstance
  3. Verify the new service-instance is “online”.

If for some reason Add-SPDistributedCacheServiceInstance doesn’t give you a healthy endpoint, try running Remove-SPDistributedCacheServiceInstance then Add-SPDistributedCacheServiceInstance on the server in question. If you still can’t get a healthy endpoint then it needs some serious consideration.

 

Command to Stop and Start the Distributed Cache service:

To start the Distributed Cache service by using Windows PowerShell:

At the Windows PowerShell command prompt, run the following command:

$instanceName =”SPDistributedCacheService Name=AppFabricCachingService”

$serviceInstance = Get-SPServiceInstance | ? {($_.service.tostring()) -eq $instanceName -and ($_.server.name) -eq $env:computername}

$serviceInstance.Provision()

To stop the Distributed Cache service by using Windows PowerShell :

At the Windows PowerShell command prompt, run the following command:

$instanceName =”SPDistributedCacheService Name=AppFabricCachingService”

$serviceInstance = Get-SPServiceInstance | ? {($_.service.tostring()) -eq $instanceName -and ($_.server.name) -eq $env:computername}

$serviceInstance.Unprovision()